Hi All,
I want to capture the some back ground activity when one insertion is going on with the help of insert select statement with the help of
RETURNING INTO Clause .
Code Snippet :
DROP TABLE t1;
DROP TABLE t;
DROP SEQUENCE t1_seq;
CREATE TABLE t1 (
id NUMBER(10),
description VARCHAR2(50),
CONSTRAINT t1_pk PRIMARY KEY (id)
);
CREATE TABLE T AS
SELECT * FROM t1 WHERE 1=2;
CREATE SEQUENCE t1_seq;
INSERT INTO t1 VALUES (t1_seq.nextval, 'ONE');
INSERT INTO t1 VALUES (t1_seq.nextval, 'TWO');
INSERT INTO t1 VALUES (t1_seq.nextval, 'THREE');
COMMIT;
SET SERVEROUTPUT ON
DECLARE
l_id t1.description%TYPE;
BEGIN
INSERT INTO t1 VALUES (t1_seq.nextval, 'FOUR')
RETURNING (SELECT CURRMVNAME FROM V$MVREFRESH WHERE CURRMVNAME ='MV_NAME') INTO l_id;
COMMIT;
DBMS_OUTPUT.put_line('ID=' || l_id);
END;
/
Above code was working fine . But our requirement was INSERT SELECT should also give the support for this RETURNING Clause
INSERT INTO t1 select * from MV_NAME
RETURNING (SELECT CURRMVNAME FROM V$MVREFRESH WHERE CURRMVNAME ='MV_NAME') INTO l_id;
This is not working.
Can we capture the same mv refresh was going on or not when we are performing the DML operations from the same table.
Thanks
SaiPradyumn