9.14. ROW_COUNT
Available in
PSQL
Changed in
2.0
Type
INTEGER
Description
The ROW_COUNT
context variable contains the number of rows affected by the most recent DML statement (INSERT
, UPDATE
, DELETE
, SELECT
or FETCH
) in the current trigger, stored procedure or executable block.
Example
update Figures set Number = 0 where id = :id;
if (row_count = 0) then
insert into Figures (id, Number) values (:id, 0);
Behaviour with SELECT
and FETCH
After a singleton
SELECT
,ROW_COUNT
is 1 if a data row was retrieved and 0 otherwise.In a
FOR SELECT
loop,ROW_COUNT
is incremented with every iteration (starting at 0 before the first).After a
FETCH
from a cursor,ROW_COUNT
is 1 if a data row was retrieved and 0 otherwise. Fetching more records from the same cursor does not incrementROW_COUNT
beyond 1.In Firebird 1.5.x,
ROW_COUNT
is 0 after any type ofSELECT
statement.
|