Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How SQL%ROWCOUNT works

926749Apr 3 2012 — edited Apr 12 2012
How SQL%ROWCOUNT works ...............plz help


PL/SQL code is:



SET SERVEROUTPUT ON

DECLARE
avg_1 NUMBER;
avg_2 NUMBER;
var_rows NUMBER;
BEGIN
SELECT AVG(salary) INTO avg_1 FROM employees where department_id=10;
SELECT AVG(salary) INTO avg_1 FROM employees where department_id=20;

if avg_1 > avg_2 THEN

UPDATE employees SET salary=(salary *20/100)+ salary
where department_id=20;

IF SQL%NOTFOUND THEN

dbms_output.put_line('None of the salaries where updated');

ELSIF SQL%FOUND THEN

var_rows := SQL%ROWCOUNT;

dbms_output.put_line('Salaries for ' || var_rows || 'employees are updated');

END IF;
end if;
end;





anonymous block completed

PL/SQL procedure successfully completed.

The PLSQL Procedure was executed succesfully.
But DBMS_OUTPUT.PUT_LINE(v_count); have not displayed anything.

How SQL%ROWCOUNT works?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 10 2012
Added on Apr 3 2012
5 comments
276,874 views