• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Doing SQL from PL/SQL:Best and Worst Practices
 An Oracle White Paper September 2008 
 
Doing SQL from PL/SQL: Best and Worst Practices21-September-2008www.oracle.com/technology/tech/pl_sql/pdf/doing_sql_from_plsql.pdf 
NOTE
 The following is intended to outline our general product direction. it is intendedfor information purposes only, and may not be incorporated into any contract. Itis not a commitment to deliver any material, code, or functionality, and shouldnot be relied upon in making purchasing decisions. The development, release,and timing of any features or functionality described for Oracle’s productsremains at the sole discretion of Oracle.
 
Doing SQL from PL/SQL: Best and Worst Practices21-September-2008www.oracle.com/technology/tech/pl_sql/pdf/doing_sql_from_plsql.pdf 
Doing SQL from PL/SQL:Best and Worst Practices
CONTENTS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2Caveat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3Periodic revision of this paper. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
DBMS_Sql 
API
. . . . . . . . . . . . . .5EmbeddedSQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
. . . . . . . . . . . . . . . . . . . . . .6
. .8
. . . . . . . . . . .9
. . . . . . . . .10NativedynamicSQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 The
DBMS_Sql 
API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15Cursor taxonomy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
. . . . . . . . . . . . . . . . . . . . . . . . . .17
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
sharableSQLstructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
session cursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
implicitcursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
explicitcursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
refcurso. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
cursorvariable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
strongrefcurso. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
weakrefcurso. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
identifiedcursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24
DBMS_Sqlnumericcursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
explicitcursorattribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
implicitcursorattribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
select 
statements
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30Selecting many rows — unbounded result set. . . . . . . . . . . . . . . . . . . . . . . .30
 fetch 
loop
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32Selecting many rows — bounded result set. . . . . . . . . . . . . . . . . . . . . . . . . .33Selecting many rows — 
selectlis
or binding requirementnot known until run-time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35Selecting a single row . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 Approaches for producer/consumer modularization. . . . . . . . . . . . . . . . . .41
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
. . . . . . . . . . . . . . . . . . . . . . . . . . . .45
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...