Categories:
.NET (961)
C (387)
C++ (185)
CSS (84)
DBA (8)
General (31)
HTML (48)
Java (641)
JavaScript (220)
JSP (109)
JUnit (31)
MySQL (297)
Networking (10)
Oracle (562)
Perl (48)
Perl (9)
PHP (259)
PL/SQL (140)
RSS (51)
Software QA (28)
SQL Server (5)
Struts (20)
Unix (2)
Windows (3)
XHTML (199)
XML (59)
Other Resources:
How To Assign Data of the Deleted Row to Variables
How To Assign Data of the Deleted Row to Variables? - Oracle DBA FAQ - Working with Database Objects in PL/SQL
✍: FYIcenter.com
If a DELETE statement is deleting a single row, you can assign column values of the deleted row to variables by using the RETURNING clause, which an extension of DELETE statements for PL/SQL. The tutorial script shows you how to do this:
CREATE TABLE emp_temp AS SELECT * FROM employees; DECLARE fname VARCHAR2(10); lname VARCHAR2(10); BEGIN DELETE FROM emp_temp WHERE employee_id = 100; RETURNING first_name, last_name INTO fname, lname; DBMS_OUTPUT.PUT_LINE('Name deleted = ' || fname || ' ' || lname); -- This will not work because multiple rows deleted -- DELETE FROM emp_temp WHERE employee_id > 100; -- RETURNING first_name, last_name INTO fname, lname; END; / Name deleted = Steven King
Similar to SELECT ... INTO, RETURNING ... INTO will not work if multiple rows are deleted.
2007-04-27, 4637👍, 0💬
Popular Posts:
What is thread? A thread is an independent path of execution in a system.
Can each Java object keep track of all the threads that want to exclusively access to it?
How To Control Padding Spaces within a Table Cell? - XHTML 1.0 Tutorials - Understanding Tables and ...
How do we assign page specific attributes ? Page attributes are specified using the @Page directive.
How To Merge Values of Two Arrays into a Single Array? - PHP Script Tips - PHP Built-in Functions fo...