|
-
It works like this (in a simplified schema):
Script:
SET SERVEROUT ON
CREATE TABLE T2
(
X NUMBER
);
CREATE OR REPLACE PACKAGE PK1 AS
TYPE T_TAB_X IS TABLE OF T2%ROWTYPE INDEX BY PLS_INTEGER;
TAB_X T_TAB_X;
PROCEDURE P;
END PK1;
/
CREATE OR REPLACE PACKAGE BODY PK1 AS
PROCEDURE P IS
vCmd VARCHAR2(999);
BEGIN
-- populate the test table
FOR i IN 1 .. 5 LOOP
INSERT INTO T2(X)
VALUES (i);
END LOOP;
vCmd := 'BEGIN ' ||
'DELETE FROM T2 RETURNING X BULK COLLECT INTO PK1.TAB_X; ' ||
'END;';
EXECUTE IMMEDIATE vCmd;
FOR i IN TAB_X.FIRST .. TAB_X.LAST LOOP
DBMS_OUTPUT.PUT_LINE(TAB_X(i).X);
END LOOP;
END P;
END PK1;
/
EXEC PK1.P
Output:
1
2
3
4
5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|