How to use the new database function PL/SCOPE
This article focuses on "how to use the new database function PL/SCOPE", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the new database function PL/SCOPE.
I opened PL/Scope in the session:
ALTER SESSION SET plscope_settings='identifiers:all'/
Then I created the following tables and packages:
CREATE TABLE plch_stuff (amount NUMBER, rating INTEGER) / CREATE OR REPLACE PACKAGE plch_pkgIS PROCEDURE do_stuff;END plch_pkg;/CREATE OR REPLACE PACKAGE BODY plch_pkg.END plch_pkg;/
Oh, I'm sorry, I can't let you see the code of the package! Please continue.
I make the following query on the USER_IDENTIFIERS view of PL/Scope:
SELECT type, usage FROM user_identifiersWHERE object_name = 'PLCH_PKG'ORDER BY 1,2 /
I see these results:
TYPE USAGE--FUNCTION CALL ITERATOR DECLARATIONITERATOR REFERENCE LABEL DECLARATIONPACKAGE DECLARATIONPACKAGE DEFINITIONPROCEDURE DECLARATIONPROCEDURE DEFINITIONVARIABLE DECLARATIONVARIABLE REFERENCE VARIABLE REFERENCE
Which of the following sentences about the plch_pkg package are correct?
(A)
There are no PRIVATE subroutines in the package.
(B)
The do_stuff procedure may contain a FORALL statement.
(C)
The package must contain a variable at the PACKAGE level (that is, it is not declared in do_stuff).
(D)
The do_stuff procedure must contain a GOTO statement. 2011-11-9 answer AB. (a) there are no PRIVATE subroutines in the package. You will see two records corresponding to the process defined in each package: PROCEDURE DECLARATIONPROCEDURE DEFINITION corresponds to the function defined in each package and you will see two records: FUNCTION DECLARATIONFUNCTION DEFINITION result only has such a pair: PROCEDURE DECLARATIONPROCEDURE DEFINITION it corresponds to the do_stuff process, there are no other subroutines. (B) the do_stuff procedure may contain a FORALL statement. A FORALL statement is like a FOR loop that defines and uses implicit cursors. These two lines in the output: ITERATOR DECLARATIONITERATOR REFERENCE may correspond to FORALL statements. (C) the package must contain a variable at the PACKAGE level (that is, it is not declared in do_stuff). This is only "possible", not "necessary". We know that there is a variable defined somewhere in the package body, based on these two lines of output: VARIABLE DECLARATIONVARIABLE REFERENCE, but this variable may be defined inside the do_stuff. To determine whether this variable is PACKAGE-level, you must know the minimum line number of all program units, and then see if the variable defines the line number before that. (d) the do_stuff procedure must contain a GOTO statement. There is this line in the output: LABEL DECLARATION, so we know that a label is declared, and it may appear somewhere in the program, like this: but the output does not indicate that the label is referenced, otherwise we should see another line of output: LABEL REFERENCE (newkid note: even if you see the label referenced Also does not mean that GOTO, for example, out of the loop EXIT can also quote the label) here, I believe you have a deeper understanding of "how to use the new database feature PL/SCOPE", might as well to actual operation it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!