Usage of returning into in PL/SQL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.