Home » SQL & PL/SQL » SQL & PL/SQL » Not able to insert with returning option on view with instead of trigger (11g)
Not able to insert with returning option on view with instead of trigger [message #646826] Mon, 11 January 2016 03:07 Go to next message
saini006
Messages: 9
Registered: July 2008
Location: hyderabad
Junior Member
  CREATE TABLE BANK 
   (	TRAN_ID NUMBER(10,0), 
	TRAN_TYPE VARCHAR2(5 BYTE), 
	AMMOUNT NUMBER(6,2), 
	LOAD_DATE TIMESTAMP (6)
   );

create  view v_bank as select * from bank;

create or replace 
TRIGGER IOI_bank
  INSTEAD OF INSERT
  ON v_bank
  
  for each row
  
DECLARE NUMROWS INTEGER;
V_LOB ACCOUNT_PROGRAMS.LINE_OF_BUSINESS%TYPE;
BEGIN

 DBMS_OUTPUT.PUT_LINE('v_lob  '||v_lob); 
  Insert into BANK
    (TRAN_ID,
      TRAN_TYPE,
      AMMOUNT,
      LOAD_DATE
    )
   values
    (:new.TRAN_ID
    ,:new.TRAN_TYPE
    ,:NEW.AMMOUNT
    ,:NEW.LOAD_DATE);
END;

SET SERVEROUTPUT ON
DECLARE
V_NUM NUMBER;
BEGIN
INSERT INTO V_BANK
VALUES (1,'BA',100,SYSDATE) RETURNING TRAN_ID INTO  V_NUM;
DBMS_OUTPUT.PUT_LINE('333333 '||V_NUM); 
END;
/


I am getting below error while inserting v_bank

Error report:
ORA-22816: unsupported feature with RETURNING clause
ORA-06512: at line 4

can you please suggest. I am sending example of my code.

Thanks in Advance
Santosh



CM: fixed the code tags. Out code tags are [code] and [/code] not {code}

[Updated on: Mon, 11 January 2016 03:13] by Moderator

Report message to a moderator

Re: Not able to insert with returning option on view with instead of trigger [message #646827 is a reply to message #646826] Mon, 11 January 2016 03:12 Go to previous messageGo to next message
cookiemonster
Messages: 13975
Registered: September 2008
Location: Rainy Manchester
Senior Member
Error message is pretty clear. Returning doesn't work on views with instead of triggers.
And if you look in the documentation for the insert statement in section on the returning clause it explicitly states that.

[Updated on: Mon, 11 January 2016 03:12]

Report message to a moderator

Re: Not able to insert with returning option on view with instead of trigger [message #646828 is a reply to message #646826] Mon, 11 January 2016 03:17 Go to previous messageGo to next message
John Watson
Messages: 9002
Registered: January 2010
Location: Global Village
Senior Member
You are not telling the truth! Your trigger did not compile, becaue of this,
SET SERVEROUTPUT ON


--update: sorry, I misread your code.

[Updated on: Mon, 11 January 2016 03:20]

Report message to a moderator

Re: Not able to insert with returning option on view with instead of trigger [message #646851 is a reply to message #646828] Mon, 11 January 2016 22:33 Go to previous message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
This is a known limitation. It has been this way since both features were available. It is just another example of how "advanced" features in Oracle do not always work with each other.

In the end you will have to choose, which do you want more, (TRIGGERS vs. RETURNING).

Sorry, that's life. Good to see someone giving the database a workout though. Keep going.

Kevin
Previous Topic: Pull 20 records for each time
Next Topic: Not able to create the Materialized view
Goto Forum:
  


Current Time: Sun Jun 28 21:40:21 CDT 2026