Home » SQL & PL/SQL » SQL & PL/SQL » Returning into clause for insert selectstatements (Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production)
Returning into clause for insert selectstatements [message #676398] Fri, 07 June 2019 07:28 Go to previous message
saipradyumn
Messages: 419
Registered: October 2011
Location: Hyderabad
Senior Member
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Different Values of RAWTOHEX in Oracle 12c and 11g
Next Topic: MV Refresh On Commit
Goto Forum:
  


Current Time: Fri Apr 26 06:17:51 CDT 2024