Scope create replace package body scope scope donald
Chapter 3 ■ types, Variables, and sCope
08 -- Here's a global variable declaration
09 gv_scope varchar2(80) := 10 'I''m a global (or package spec)
variable';
11
12 -- Here's a global (or package spec) function declaration 13 FUNCTION
my_scope_is_global
14 return varchar2;
15
16 -- Here's a global (or package spec) procedure declaration 17
PROCEDURE my_scope_is_global;
18
19
20 end SCOPE;
21 /
22 @se.sql SCOPE
33
34
35 -- Here's an instance (or package body) procedure declaration
36 PROCEDURE my_scope_is_instance is
37 v_answer_3 varchar2(3) := 'Yes';
38 begin
39 pl(chr(9)||'Can procedure my_scope_is_instance see variable
gv_scope?'); 40 pl(chr(9)||gv_scope);
41 pl(v_answer_3);
42 end my_scope_is_instance;
43
44
45 -- Here's a global (or package spec) procedure declaration
46 PROCEDURE my_scope_is_global is
47 v_answer_4 varchar2(3) := 'Yes';
48 begin
49 pl(chr(9)||'Can procedure my_scope_is_global see variable
iv_scope?'); 50 pl(chr(9)||iv_scope);
51 pl(v_answer_4);
52 end my_scope_is_global;
53
54
55 end SCOPE;
56 /
57 @se.sql SCOPE
Take some time to look over the two code listings. At this point, you should be able to understand the PL/SQL block structure of the package, and the methods declared and implemented in it, along with the variable declarations. The point now is to understand when a given function, procedure, or variable is in scope.