Вы находитесь на странице: 1из 1

8/17/2014 Package Function with ' PRAGMA AUTONOMOUS_TRANSACTION' : Package Body Function Procedure Packages Oracle PL/SQL Tutorial

http://www.java2s.com/Tutorial/Oracle/0540__Function-Procedure-Packages/PackageFunctionwithPRAGMAAUTONOMOUSTRANSACTION.htm 1/2
Package Function with 'PRAGMA AUTONOMOUS_TRANSACTION' : Package Body Function Procedure Packages Oracle PL/SQL Tutorial
Home
Oracle PL/SQL
Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update
Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String
Functions
12. Aggregate
Functions
13. Date Timestamp
Functions
14. Numerical Math
Functions
15. Conversion
Functions
16. Analytical
Functions
17. Miscellaneous
Functions
18. Regular
Expressions
Functions
19. Statistical
Functions
20. Linear Regression
Functions
21. PL SQL Data
Types
22. PL SQL
Statements
23. PL SQL Operators
24. PL SQL
Programming
25. Cursor
26. Collections
27. Function
Procedure
Packages
28. Trigger
29. SQL PLUS
Session
Environment
30. System Tables
Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Oracle PL/SQL Tutorial Function Procedure Packages Package
Body
Search
SQL>
SQL>
SQL> CREATE TABLE stuff_to_fix
2 (stuff VARCHAR2(1000),
3 fixed VARCHAR2(1));
Table created.
SQL>
SQL> CREATE OR REPLACE PACKAGE fixer AS
2
3 PROCEDURE fix_stuff;
4 PROCEDURE fix_this ( p_thing_to_fix VARCHAR2 );
5
6 END fixer;
7 /
Package created.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY fixer AS
2
3 PROCEDURE fix_this ( p_thing_to_fix VARCHAR2 ) IS
4 PRAGMA AUTONOMOUS_TRANSACTION;
5 BEGIN
6 INSERT INTO stuff_to_fix(stuff,fixed)VALUES(p_thing_to_fix,'N');
7 COMMIT;
8 END fix_this;
9
10 PROCEDURE fix_stuff IS
11 CURSOR curs_get_stuff_to_fix IS
12 SELECT stuff,ROWID FROM stuff_to_fix WHERE fixed = 'N';
13
14 BEGIN
15
16 FOR v_stuff_rec IN curs_get_stuff_to_fix LOOP
17
18 EXECUTE IMMEDIATE v_stuff_rec.stuff;
19
20 UPDATE stuff_to_fix SET fixed = 'Y' WHERE ROWID = v_stuff_rec.rowid;
21
22 END LOOP;
23
24 COMMIT;
25
26 END fix_stuff;
27
28 END fixer;
29 /
Package body created.
SQL>
SQL> DROP TABLE stuff_to_fix;
Table dropped.
SQL>
Ad by Mov ie Mode

Вам также может понравиться