Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Why is RowsAffected(Statement)=0 for Insert?
Sat, May 9 2015 9:28 PMPermanent Link

Barry

I have a stored procedure that looks like:

Declare _Cursor               Sensitive    Cursor for _Stmt;

Prepare 'select * from table where Num1 = 0';
Open _Cursor;
Fetch First From _Cursor;
if EOF(_Cursor) then
 Insert into _Cursor ('col1','col2'...) values('val1','val2');
 set _Ok = RowsAffected(_Stmt) > 0;   -- _Ok is always FALSE even if a row is added.
end if;

It seems RowsAffected(_Stmt) always returns 0 when a new row is Inserted,
although RowsAffected(_Stmt) returns 1 if I Update a row.

Does RowsAffected(Statement) not work for Insert statements?

I'm using v 2.13 B2 Unicode.

TIA
Barry
Fri, May 15 2015 2:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Barry,

<< It seems RowsAffected(_Stmt) always returns 0 when a new row is Inserted,
although RowsAffected(_Stmt) returns 1 if I Update a row. >>

No, it always returns 0 when you're using a *cursor* insert to perform the
insertion.  If you were to use an actual INSERT statement, then it would
return the correct value.  Cursor inserts *always* work, or they return an
exception, and they are always a single operation (rows affected=1).

Tim Young
Elevate Software
www.elevatesoft.com
Image