Home » SQL & PL/SQL » SQL & PL/SQL » How to obtain Rows affected in PL/SQL???
How to obtain Rows affected in PL/SQL??? [message #38339] Fri, 12 April 2002 00:45 Go to next message
O. Vamsi Krishna
Messages: 3
Registered: January 2002
Junior Member
Hi,
Is there any way to obtain the rows affected by a SQL statement(Insert, Update, Delete, Select) in PL/SQL?

There is a structure SQLCA available for PRO*C. Is there anything similar to this in PL/SQL?

Thanks and Regards,
Vamsi
Re: How to obtain Rows affected in PL/SQL??? [message #38343 is a reply to message #38339] Fri, 12 April 2002 04:58 Go to previous messageGo to next message
OKIK
Messages: 3
Registered: April 2002
Junior Member
Try DBMS_SQL.EXECUTE

...like this in your script
rowsAffected := EXEC_SQL.EXECUTE(ConnectionHandle, cursorNo)
Re: How to obtain Rows affected in PL/SQL??? [message #38346 is a reply to message #38339] Fri, 12 April 2002 09:16 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
SQL%ROWCOUNT will provide the number of rows involved in the last DML (insert/update/delete) statement. This is not applicable to a SELECT statement though.

sql>begin
  2    update user_master
  3       set dept_id = 'ABC'
  4     where dept_id = 'CIS';
  5     
  6    dbms_output.put_line( 'Rows affected: ' || sql%rowcount );
  7  end;
  8  /
Rows affected: 86

PL/SQL procedure successfully completed.
Re: How to obtain Rows affected in PL/SQL??? [message #38353 is a reply to message #38339] Fri, 12 April 2002 23:06 Go to previous message
Eric
Messages: 78
Registered: April 1999
Member
Use ---> SQL%ROWCOUNT like Todd suggested.

KISS
Previous Topic: date
Next Topic: %datatype
Goto Forum:
  


Current Time: Fri Apr 26 08:12:02 CDT 2024