CREATE OR REPLACE PROCEDURE AddInterest
( bankname VARCHAR, rate DECIMAL)
AS
BEGIN
UPDATE Deposit SET balance = balance + (balance * rate / 100)
WHERE branchname = bankname;
**dbms_output.put_line(bankname ||rate );**
END;
/
in my code, the dbms_output, I want to output what i have edited from the deposit account. Please help.
Declare a variable UpdatedRecords
of TABLE OF Deposit%ROWTYPE
and add RETURNING BULK COLLECT
-clause to your UPDATE
statement.
UPDATE ... RETURNING <all fields> BULK COLLECT INTO UpdatedRecords;
After the execution UpdatedRecords
variable will be a collection of updated records as they were looking before changes. Scan it with LOOP
and print what ever you want.
You can also reduce a number of fields collected after the executeion, just change RETURNING
clause and give the proper declaration for UpdatedRecords
variable.
Refer to Oracle documentation http://docs.oracle.com/database/121/LNPLS/returninginto_clause.htm#LNPLS01354 for RETUNING
clause.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.