Home » SQL & PL/SQL » SQL & PL/SQL » trapping no records on update
trapping no records on update [message #39902] Thu, 22 August 2002 05:31 Go to next message
John Bonin
Messages: 3
Registered: August 2002
Junior Member
I'm trying to implement a counter of the number of records not updated in one table from a cursor loop in
another table.

for test in tmpcursor
loop
id := test.dbid;
update othertable
set newid = id
where dbid = id;
-- right here I want to check for sqlcode = 100 if the
-- data wasn't found to update and add to counter.
end loop;

Any ideas how to do this?

Thanks,
John
Re: trapping no records on update [message #39903 is a reply to message #39902] Thu, 22 August 2002 06:32 Go to previous messageGo to next message
Rick Cale
Messages: 111
Registered: February 2002
Senior Member
Use SQL%ROWCOUNT, this returns # of rows affected on
last DML statement. You could initialize a variable to
0 and just do variable := variable + SQL%ROWCOUNT to
keep a cumulative total.
Re: trapping no records on update [message #39905 is a reply to message #39902] Thu, 22 August 2002 07:34 Go to previous message
John Bonin
Messages: 3
Registered: August 2002
Junior Member
Thanks! works great.

John
Previous Topic: Can you help with this simple SQL query?
Next Topic: Capturing the number of rows selected
Goto Forum:
  


Current Time: Thu Mar 28 14:04:13 CDT 2024