Preface |
|
xvii | |
Acknowledgments |
|
xxi | |
About the Authors |
|
xxiii | |
Introduction to PL/SQL New Features in Oracle 12c |
|
xxv | |
|
Invoker's Rights Functions Can Be Result-Cached |
|
|
xxvi | |
|
More PL/SQL-Only Data Types Can Cross the PL/SQL-to-SQL Interface Clause |
|
|
xxvii | |
|
|
xxvii | |
|
|
xxviii | |
|
Roles Can Be Granted to PL/SQL Packages and Stand-Alone Subprograms |
|
|
xxix | |
|
More Data Types Have the Same Maximum Size in SQL and PL/SQL |
|
|
xxx | |
|
Database Triggers on Pluggable Databases |
|
|
xxx | |
|
LIBRARY Can Be Defined as a DIRECTORY Object and with a CREDENTIAL Clause |
|
|
xxx | |
|
Implicit Statement Results |
|
|
xxxi | |
|
BEQUEATH CURRENT USER Views |
|
|
xxxii | |
|
INHERIT PRIVILEGES and INHERIT ANY PRIVILEGES Privileges |
|
|
xxxii | |
|
|
xxxiii | |
|
Objects, Not Types, Are Editioned or Noneditioned |
|
|
xxxiv | |
|
PL/SQL Functions That Run Faster in SQL |
|
|
xxxiv | |
|
Predefined Inquiry Directives $$PLSQL_UNIT_OWNER and $$PLSQLUNITTYPE |
|
|
xxxvi | |
|
Compilation Parameter PLSQL_DEBUG Is Deprecated |
|
|
xxxvii | |
Chapter 1 PL/SQL Concepts |
|
1 | (26) |
|
Lab 1.1 PL/SQL Architecture |
|
|
2 | (7) |
|
|
2 | (3) |
|
|
5 | (3) |
|
|
8 | (1) |
|
Lab 1.2 PL/SQL Development Environment |
|
|
9 | (9) |
|
Getting Started with SQL Developer |
|
|
10 | (1) |
|
Getting Started with SQL*Plus |
|
|
11 | (3) |
|
|
14 | (4) |
|
Lab 1.3 PL/SQL: The Basics |
|
|
18 | (7) |
|
DBMS_OUTPUT.PUT_LINE Statement |
|
|
18 | (1) |
|
Substitution Variable Feature |
|
|
19 | (6) |
|
|
25 | (2) |
Chapter 2 PL/SQL Language Fundamentals |
|
27 | (16) |
|
Lab 2.1 PL/SQL Programming Fundamentals |
|
|
28 | (13) |
|
PL/SQL Language Components |
|
|
28 | (1) |
|
|
29 | (3) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (2) |
|
Declare and Initialize Variables |
|
|
36 | (3) |
|
Scope of a Block, Nested Blocks, and Labels |
|
|
39 | (2) |
|
|
41 | (2) |
Chapter 3 SQL in PL/SQL |
|
43 | (14) |
|
Lab 3.1 DML Statements in PL/SQL |
|
|
44 | (5) |
|
Initialize Variables with SELECT INTO |
|
|
44 | (1) |
|
Using the SELECT INTO Syntax for Variable Initialization |
|
|
45 | (2) |
|
Using DML in a PL/SQL Block |
|
|
47 | (1) |
|
Using a Sequence in a PL/SQL Block |
|
|
48 | (1) |
|
Lab 3.2 Transaction Control in PL/SQL |
|
|
49 | (6) |
|
Using COMMIT, ROLLBACK, and SAVEPOINT |
|
|
49 | (4) |
|
Putting Together DML and Transaction Control |
|
|
53 | (2) |
|
|
55 | (2) |
Chapter 4 Conditional Control: IF Statements |
|
57 | (14) |
|
|
58 | (5) |
|
|
58 | (2) |
|
|
60 | (3) |
|
|
63 | (4) |
|
Lab 4.3 Nested I F Statements |
|
|
67 | (3) |
|
|
70 | (1) |
Chapter 5 Conditional Control: CASE Statements |
|
71 | (20) |
|
|
71 | (9) |
|
|
72 | (2) |
|
|
74 | (6) |
|
|
80 | (4) |
|
Lab 5.3 NULLIF and COALESCE Functions |
|
|
84 | (5) |
|
|
84 | (3) |
|
|
87 | (2) |
|
|
89 | (2) |
Chapter 6 Iterative Control: Part I |
|
91 | (20) |
|
|
92 | (6) |
|
|
93 | (4) |
|
|
97 | (1) |
|
|
98 | (6) |
|
|
98 | (3) |
|
Premature Termination of the WHILE Loop |
|
|
101 | (3) |
|
Lab 6.3 Numeric FOR Loops |
|
|
104 | (5) |
|
Using the IN Option in the Loop |
|
|
105 | (2) |
|
Using the REVERSE Option in the Loop |
|
|
107 | (1) |
|
Premature Termination of the Numeric FOR Loop |
|
|
108 | (1) |
|
|
109 | (2) |
Chapter 7 Iterative Control: Part II |
|
111 | (12) |
|
Lab 7.1 CONTINUE Statement |
|
|
111 | (7) |
|
|
112 | (3) |
|
|
115 | (3) |
|
|
118 | (4) |
|
|
118 | (2) |
|
|
120 | (2) |
|
|
122 | (1) |
Chapter 8 Error Handling and Built-in Exceptions |
|
123 | (10) |
|
|
124 | (2) |
|
Lab 8.2 Built-in Exceptions |
|
|
126 | (6) |
|
|
132 | (1) |
Chapter 9 Exceptions |
|
133 | (16) |
|
|
133 | (4) |
|
Lab 9.2 User-Defined Exceptions |
|
|
137 | (4) |
|
Lab 9.3 Exception Propagation |
|
|
141 | (6) |
|
|
146 | (1) |
|
|
147 | (2) |
Chapter 10 Exceptions: Advanced Concepts |
|
149 | (10) |
|
Lab 10.1 RAISE_APPLICATION_ERROR |
|
|
149 | (4) |
|
Lab 10.2 EXCEPTION_INIT Pragma |
|
|
153 | (2) |
|
Lab 10.3 SQLCODE and SQLERRM |
|
|
155 | (3) |
|
|
158 | (1) |
Chapter 11 Introduction to Cursors |
|
159 | (24) |
|
Lab 11.1 Types of Cursors |
|
|
159 | (6) |
|
Making Use of an Implicit Cursor |
|
|
160 | (1) |
|
Making Use of an Explicit Cursor |
|
|
161 | (4) |
|
|
165 | (10) |
|
Processing an Explicit Cursor |
|
|
165 | (3) |
|
Making Use of a User-Defined Record |
|
|
168 | (2) |
|
Making Use of Cursor Attributes |
|
|
170 | (5) |
|
Lab 11.3 Cursor FOR LOOPS |
|
|
175 | (2) |
|
Making Use of Cursor FOR LOOPS |
|
|
175 | (2) |
|
|
177 | (4) |
|
Processing Nested Cursors |
|
|
177 | (4) |
|
|
181 | (2) |
Chapter 12 Advanced Cursors |
|
183 | (8) |
|
Lab 12.1 Parameterized Cursors |
|
|
183 | (2) |
|
|
184 | (1) |
|
Lab 12.2 Complex Nested Cursors |
|
|
185 | (2) |
|
Lab 12.3 FOR UPDATE and WHERE CURRENT Cursors |
|
|
187 | (3) |
|
|
187 | (2) |
|
FOR UPDATE OF in a Cursor |
|
|
189 | (1) |
|
WHERE CURRENT OF in a Cursor |
|
|
189 | (1) |
|
|
190 | (1) |
Chapter 13 Triggers |
|
191 | (22) |
|
Lab 13.1 What Triggers Are |
|
|
191 | (14) |
|
|
192 | (3) |
|
|
195 | (6) |
|
|
201 | (2) |
|
|
203 | (2) |
|
Lab 13.2 Types of Triggers |
|
|
205 | (6) |
|
Row and Statement Triggers |
|
|
205 | (1) |
|
|
206 | (5) |
|
|
211 | (2) |
Chapter 14 Mutating Tables and Compound Triggers |
|
213 | (12) |
|
|
213 | (4) |
|
What Is a Mutating Table? |
|
|
214 | (1) |
|
Resolving Mutating Table Issues |
|
|
215 | (2) |
|
Lab 14.2 Compound Triggers |
|
|
217 | (6) |
|
What Is a Compound Trigger? |
|
|
218 | (2) |
|
Resolving Mutating Table Issues with Compound Triggers |
|
|
220 | (3) |
|
|
223 | (2) |
Chapter 15 Collections |
|
225 | (18) |
|
|
226 | (9) |
|
|
226 | (3) |
|
|
229 | (3) |
|
|
232 | (3) |
|
|
235 | (5) |
|
Lab 15.3 Multilevel Collections |
|
|
240 | (2) |
|
|
242 | (1) |
Chapter 16 Records |
|
243 | (16) |
|
|
243 | (7) |
|
Table-Based and Cursor-Based Records |
|
|
244 | (2) |
|
|
246 | (2) |
|
|
248 | (2) |
|
|
250 | (3) |
|
Lab 16.3 Collections of Records |
|
|
253 | (4) |
|
|
257 | (2) |
Chapter 17 Native Dynamic SQL |
|
259 | (22) |
|
Lab 17.1 EXECUTE IMMEDIATE Statements |
|
|
260 | (11) |
|
Using the EXECUTE IMMEDIATE Statement |
|
|
261 | (1) |
|
How to Avoid Common ORA Errors When Using EXECUTE IMMEDIATE |
|
|
262 | (9) |
|
Lab 17.2 OPEN-FOR, FETCH, and CLOSE Statements |
|
|
271 | (9) |
|
|
272 | (1) |
|
|
272 | (1) |
|
|
273 | (7) |
|
|
280 | (1) |
Chapter 18 Bulk SQL |
|
281 | (30) |
|
Lab 18.1 FORALL Statements |
|
|
282 | (9) |
|
|
282 | (3) |
|
|
285 | (3) |
|
|
288 | (1) |
|
|
289 | (2) |
|
Lab 18.2 The BULK COLLECT Clause |
|
|
291 | (8) |
|
Lab 18.3 Binding Collections in SQL Statements |
|
|
299 | (10) |
|
Binding Collections with EXECUTE IMMEDIATE Statements |
|
|
299 | (7) |
|
Binding Collections with OPEN- FOR , FETCH, and CLOSE Statements |
|
|
306 | (3) |
|
|
309 | (2) |
Chapter 19 Procedures |
|
311 | (10) |
|
|
312 | (1) |
|
|
312 | (1) |
|
|
312 | (1) |
|
Lab 19.1 Creating Procedures |
|
|
312 | (3) |
|
Putting Procedure Creation Syntax into Practice |
|
|
313 | (1) |
|
Querying the Data Dictionary for Information on Procedures |
|
|
314 | (1) |
|
Lab 19.2 Passing Parameters IN and OUT of Procedures |
|
|
315 | (4) |
|
Using IN and OUT Parameters with Procedures |
|
|
316 | (3) |
|
|
319 | (2) |
Chapter 20 Functions |
|
321 | (12) |
|
Lab 20.1 Creating Functions |
|
|
321 | (6) |
|
Creating Stored Functions |
|
|
322 | (3) |
|
|
325 | (2) |
|
Lab 20.2 Using Functions in SQL Statements |
|
|
327 | (2) |
|
Invoking Functions in SQL Statements |
|
|
327 | (1) |
|
Writing Complex Functions |
|
|
328 | (1) |
|
Lab 20.3 Optimizing Function Execution in SQL |
|
|
329 | (2) |
|
Defining a Function Using the WITH Clause |
|
|
329 | (1) |
|
Creating a Function with the UDF Pragma |
|
|
330 | (1) |
|
|
331 | (2) |
Chapter 21 Packages |
|
333 | (40) |
|
Lab 21.1 Creating Packages |
|
|
334 | (10) |
|
Creating Package Specifications |
|
|
335 | (2) |
|
|
337 | (2) |
|
|
339 | (2) |
|
|
341 | (3) |
|
Lab 21.2 Cursor Variables |
|
|
344 | (9) |
|
Lab 21.3 Extending the Package |
|
|
353 | (13) |
|
Extending the Package with Additional Procedures |
|
|
353 | (13) |
|
Lab 21.4 Package Instantiation and Initialization |
|
|
366 | (2) |
|
Creating Package Variables During Initialization |
|
|
367 | (1) |
|
Lab 21.5 SERIALLY_ REUSABLE Packages |
|
|
368 | (3) |
|
Using the SERIALLY_REUSABLE Pragma |
|
|
368 | (3) |
|
|
371 | (2) |
Chapter 22 Stored Code |
|
373 | (12) |
|
Lab 22.1 Gathering Information about Stored Code |
|
|
373 | (9) |
|
Getting Stored Code Information from the Data Dictionary |
|
|
374 | (4) |
|
|
378 | (4) |
|
|
382 | (3) |
Chapter 23 Object Types in Oracle |
|
385 | (20) |
|
|
386 | (8) |
|
|
386 | (5) |
|
Using Object Types with Collections |
|
|
391 | (3) |
|
Lab 23.2 Object Type Methods |
|
|
394 | (10) |
|
|
395 | (3) |
|
|
398 | (1) |
|
|
398 | (1) |
|
|
399 | (5) |
|
|
404 | (1) |
Chapter 24 Oracle-Supplied Packages |
|
405 | (26) |
|
Lab 24.1 Extending Functionality with Oracle-Supplied Packages |
|
|
406 | (13) |
|
Accessing Files within PL/SQL with UTL_FILE |
|
|
406 | (4) |
|
Scheduling Jobs with DBMS_JOB |
|
|
410 | (4) |
|
Generating an Explain Plan with DBMS_XPLAN |
|
|
414 | (3) |
|
Generating Implicit Statement Results with DBMS_SQL |
|
|
417 | (2) |
|
Lab 24.2 Error Reporting with Oracle-Supplied Packages |
|
|
419 | (10) |
|
Using the DBMS_UTILITY Package for Error Reporting |
|
|
419 | (5) |
|
Using the UTL_CALL_STACK Package for Error Reporting |
|
|
424 | (5) |
|
|
429 | (2) |
Chapter 25 Optimizing PL/SQL |
|
431 | (24) |
|
Lab 25.1 PL/SQL Tuning Tools |
|
|
432 | (6) |
|
|
432 | (1) |
|
|
433 | (3) |
|
PL/SQL Hierarchical Profiler |
|
|
436 | (2) |
|
Lab 25.2 PL/SQL Optimization Levels |
|
|
438 | (6) |
|
Lab 25.3 Subprogram Inlining |
|
|
444 | (9) |
|
|
453 | (2) |
Appendix A PL/SQL Formatting Guide |
|
455 | (6) |
|
|
455 | (1) |
|
|
455 | (1) |
|
|
456 | (1) |
|
|
457 | (1) |
|
|
457 | (4) |
Appendix B Student Database Schema |
|
461 | (8) |
|
Table and Column Descriptions |
|
|
461 | (8) |
Index |
|
469 | |