Basic Oracle Concepts and Programming Question:
How To Retrieve the Count of Updated Rows?
Answer:
After running an UPDATE statement, the database server returns a count of updated rows. You can retrieve this count from a special predefined variable called SQL%ROWCOUT, as shown in the following tutorial:
CREATE TABLE emp_temp AS SELECT * FROM employees;
BEGIN
UPDATE emp_temp SET salary = salary * 1.05
WHERE salary < 5000;
DBMS_OUTPUT.PUT_LINE('# of rows updated: ' ||
SQL%ROWCOUNT);
END;
/
# of rows updated: 49
CREATE TABLE emp_temp AS SELECT * FROM employees;
BEGIN
UPDATE emp_temp SET salary = salary * 1.05
WHERE salary < 5000;
DBMS_OUTPUT.PUT_LINE('# of rows updated: ' ||
SQL%ROWCOUNT);
END;
/
# of rows updated: 49
Previous Question | Next Question |
How To Run SQL Functions in PL/SQL? | What Is the Implicit Cursor in Oracle? |