-
Notifications
You must be signed in to change notification settings - Fork 0
/
10. Persistent State of Packages (Code Samples).html
45 lines (45 loc) · 1.45 KB
/
10. Persistent State of Packages (Code Samples).html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<pre class="prettyprint linenums">---------------------------------------------------------------------------------------------
----------------------------------PERSISTENT STATE OF PACKAGES-------------------------------
---------------------------------------------------------------------------------------------
-----------------
execute dbms_output.put_line(constants_pkg.v_salary_increase);
grant execute on constants_pkg to my_user;
revoke execute on constants_pkg from my_user;
-----------------
-----------------
begin
constants_pkg.v_company_name := 'ACME';
dbms_output.put_line(constants_pkg.v_company_name);
dbms_lock.sleep(20);
end;
exec dbms_output.put_line(constants_pkg.v_company_name);
-----------------
create or replace package constants_pkg is
PRAGMA SERIALLY_REUSABLE;
v_salary_increase constant number:= 0.04;
cursor cur_emps is select * from employees;
t_emps_type employees%rowtype;
v_company_name varchar2(20) := 'ORACLE';
end;
-----------------
begin
constants_pkg.v_company_name := 'ACME';
dbms_output.put_line(constants_pkg.v_company_name);
dbms_lock.sleep(20);
end;
-----------------
declare
v_emp employees%rowtype;
begin
open constants_pkg.cur_emps;
fetch constants_pkg.cur_emps into v_emp;
dbms_output.put_line(v_emp.first_name);
close constants_pkg.cur_emps;
end;
-----------------
declare
v_emp employees%rowtype;
begin
fetch constants_pkg.cur_emps into v_emp;
dbms_output.put_line(v_emp.first_name);
end;</pre>