munotes® Sign in

PLSQL Practical Notes | B.Sc. (Information Technology) Semester 2 | Mumbai University | munotes

MU B.Sc. (Information Technology) student group Free to join

A munotes Edition munotes.in

PLSQL Practical

B.SC. (INFORMATION TECHNOLOGY) · SEMESTER 2

Strictly as per the University of Mumbai NEP syllabus in force for B.Sc. (Information Technology)

For B.Sc. (Information Technology) students of the University of Mumbai and all its affiliated colleges

Open the book ↓

munotes.in First Year

Contents

Module I PL/SQL Blocks, Variables, Control Structures, Cursors and Composite Types

  1. What PL/SQL Is, and Why SQL Alone Is Not Enough 1
  2. Setting Up: Installing Oracle, Connecting and Typing In the Lab Tables 5
  3. Your First Anonymous Block, and SET SERVEROUTPUT ON 10
  4. The Parts of a Block: DECLARE, BEGIN, EXCEPTION and END 15
  5. Variables and Constants: Declaring, Initialising and NOT NULL 20
  6. PL/SQL Data Types: NUMBER, VARCHAR2, CHAR, DATE, BOOLEAN and PLS_INTEGER 26
  7. %TYPE: A Variable That Takes Its Type From a Column 31
  8. Taking Input: Substitution Variables With & and DEFINE 34
  9. Bind Variables: VARIABLE, EXEC and PRINT 39
  10. Writing Executable Statements: Assignment, Operators and Expressions 43
  11. The Building Blocks of the Language: Identifiers, Literals, Delimiters and Comments 48
  12. SQL Functions Inside PL/SQL, and Converting Between Types 52
  13. Nested Blocks and Variable Scope 57
  14. SELECT INTO: Reading One Row Into Variables 60
  15. When SELECT INTO Finds No Row, or More Than One 63
  16. INSERT, UPDATE and DELETE From PL/SQL, and SQL%ROWCOUNT 66
  17. MERGE: Insert or Update in One Statement 69
  18. COMMIT, ROLLBACK and SAVEPOINT Inside a Block 72
  19. Sequences: What They Are and CREATE SEQUENCE 76
  20. NEXTVAL and CURRVAL, in SQL and in PL/SQL 80
  21. Gaps, ALTER SEQUENCE, DROP SEQUENCE, and Identity Columns 85
  22. Practical 1, Worked: Programs on Variables, Input and the Lab Tables 90
  23. Loops in PL/SQL: The Kinds There Are and What MU Calls Them 95
  24. The WHILE Loop 99
  25. The "Do Loop": The Basic LOOP With EXIT WHEN at the End 102
  26. The Numeric FOR Loop, and REVERSE 106
  27. Nested Loops, Loop Labels and CONTINUE 110
  28. GOTO, Labels and the NULL Statement 114
  29. Practical 2, Worked: Programs With Loops 117
  30. The IF Statement 121
  31. IF THEN ELSE 124
  32. The ELSIF Ladder 127
  33. NULL in a Condition: Three-Valued Logic 132
  34. The CASE Statement: Simple and Searched, and CASE_NOT_FOUND 138
  35. The CASE Expression, in PL/SQL and in SQL 144
  36. Practical 3, Worked: Programs With Conditions 149
  37. What a Cursor Is: The Work Area Behind Every SQL Statement 154
  38. The Implicit Cursor and Its Attributes 158
  39. The Explicit Cursor: DECLARE, OPEN, FETCH and CLOSE 162
  40. Explicit Cursor Attributes, and a Loop That Stops in the Right Place 166
  41. The Cursor FOR Loop 170
  42. The Parameterized Cursor 174
  43. FOR UPDATE and WHERE CURRENT OF 179
  44. Cursor Variables: REF CURSOR and SYS_REFCURSOR 184
  45. Practical 4, Worked: Programs With Cursors 188
  46. Composite Data Types: When One Variable Must Hold Many Values 192
  47. Records With %ROWTYPE 195
  48. User-Defined RECORD Types, and Records in INSERT and UPDATE 199
  49. Associative Arrays: INDEX BY Tables 203
  50. Nested Tables 206
  51. VARRAYs 209
  52. Collection Methods: COUNT, FIRST, LAST, NEXT, PRIOR, EXISTS, EXTEND, TRIM, DELETE and LIMIT 212
  53. Choosing a Collection, and the Errors Collections Raise 215
  54. Collections of Records 218
  55. BULK COLLECT and FORALL 224
  56. Collections Stored in Tables: Nested Table and VARRAY Columns 230
  57. Practical 5, Worked: Programs With Records and Collections 235

Module II Procedures, Functions, Triggers, Exceptions and Packages

  1. Named Blocks: What a Stored Subprogram Is 240
  2. Creating and Running a Procedure 244
  3. Procedure Parameters: IN, OUT and IN OUT 247
  4. Passing Parameters: Positional, Named and Mixed Notation, and DEFAULT 252
  5. When a Procedure Will Not Compile: SHOW ERRORS and USER_ERRORS 256
  6. Where a Subprogram Lives: USER_SOURCE, USER_OBJECTS, Recompiling and Dropping 260
  7. Procedures That Change Data, and Who Commits 263
  8. Local Subprograms, and One Procedure Calling Another 269
  9. Practical 6, Worked: Programs With Procedures 274
  10. Creating a Function: RETURN and Its Rules 279
  11. Calling a Function: From PL/SQL, From SQL and at the SQL Prompt 283
  12. What a Function Called From SQL May Not Do 287
  13. Recursive Functions: Factorial and Fibonacci 291
  14. Procedure or Function: How to Choose 295
  15. Practical 7, Worked: Programs With Functions 298
  16. What a Trigger Is, and When It Fires 303
  17. The Row Level Trigger: FOR EACH ROW, :NEW and :OLD 310
  18. BEFORE Row Triggers That Correct or Reject a Row 314
  19. AFTER Row Triggers: Keeping an Audit Trail 319
  20. INSERTING, UPDATING and DELETING, UPDATE OF and the WHEN Clause 324
  21. The Statement Level Trigger 328
  22. Row and Statement Triggers Together: The Order They Fire In 333
  23. The INSTEAD OF Trigger on a View 337
  24. The Mutating Table Error, and Compound Triggers 341
  25. Managing Triggers: Disabling, Enabling, Dropping and USER_TRIGGERS 345
  26. Triggers on Other Events: DDL and Database Events 349
  27. Practical 8, Worked: Programs With Triggers 356
  28. Exceptions: What Happens When a Block Fails 362
  29. The EXCEPTION Section, WHEN and WHEN OTHERS 366
  30. Oracle's Predefined Exceptions 370
  31. Naming an Oracle Error Yourself: PRAGMA EXCEPTION_INIT 374
  32. User-Defined Exceptions: Declare, RAISE and Handle 377
  33. RAISE_APPLICATION_ERROR 380
  34. SQLCODE and SQLERRM 386
  35. How an Exception Travels: Propagation and Re-raising 390
  36. Practical 9, Worked: Programs With Exceptions 396
  37. What a Package Is: Specification and Body 401
  38. Creating a Package: A First Specification and Body 405
  39. Public and Private Parts, and Package Variables That Remember 409
  40. Overloading: Two Subprograms With One Name 413
  41. The Initialisation Section, and Forward Declarations 417
  42. Oracle's Own Packages: DBMS_OUTPUT Up Close 421
  43. Managing Packages: USER_SOURCE, Recompiling and Dropping 425
  44. Practical 10, Worked: A Complete Package for the Lab Tables 432

Module J The journal and the practical examination

  1. What Goes in the Journal, and the Shape of One Write-up 438
  2. The Practical Examination: Two Hours, Thirty Marks 442
  3. Sample Practical Slips for Module 1, Worked 446
  4. Sample Practical Slips for Module 2, Worked 451
  5. The Viva: What Is Asked, and How to Answer 457
munotes.in

The chapters are locked

Get the notes to read all 106 chapters of this book.

The rest of this subject

These notes are cut from the University's printed syllabus. Open the syllabus itself for the same subject.

Issue
Done!