March 24th, 2012, 01:18 AM
Firebird Query Help
Is there any way to get the affected row count after executing a delete query.
Delete from TBL_NAME where Id=1 returning rows_affected ;
i tried but shows error in query..
Looking for your help..
You could just take a COUNT using the same WHERE statement before you delete. For example:
As long as you use the same WHERE statement, that exact number of records will be deleted.
SELECT COUNT(*) FROM TBL_NAME WHERE Id=1;
@aravindu: If you are fine doing that in PSQL (stored procedure, trigger, execute block), then check out the ROW_COUNT context variable. Usually, access components like IBObjects, IBDAC ... AFAIK also offers a property which gives you the "rows affected", but this isn't part of the SQL statement then.
@joeflinthiggins: Only when running the SELECT and the DELETE in a single SNAPSHOT transaction.