The returning into statement can be specified in an Oracle DML statement. The use of the returning into statement can in many cases simplify PL/SQL programming and one less SELECT INTO statement.
Delete operation: Returning returns the result before the delete;
Insert operation: Returning returns the result after insert;
Update operation: The returning statement is the result of returning the update operation.
--Created on 2015/11/5 Thursday by Yancong-zhang
--the usage of returning
DECLARE
--Local variables here
I INTEGER;
L_tid number;
L_tname VARCHAR2 (200);
L_tage number;
BEGIN
--Test statements here
--Returns the data to be inserted
INSERT into Zyc
VALUES
(4, ' WY ', 20)
Returning Tid, Tname, Tage into L_tid, L_tname, l_tage;
Dbms_output.put_line (L_tid | | '-' | | L_tname | | '-' | | L_tage);
--Returns the data to be deleted
DELETE Zyc
WHERE tid = 1
Returning Tid, Tname, Tage into L_tid, L_tname, l_tage;
Dbms_output.put_line (L_tid | | '-' | | L_tname | | '-' | | L_tage);
--Returns the data to be updated
UPDATE Zyc
SET tid = 5, Tname = ' lwj ', Tage = 22
WHERE tid = 2
Returning Tid, Tname, Tage into L_tid, L_tname, l_tage;
Dbms_output.put_line (L_tid | | '-' | | L_tname | | '-' | | L_tage);
COMMIT;
END;
Usage of returning into in PL/SQL