Subject Re: [firebird-support] Rows affected...
Author Alexandre Benson Smith
Rasmus Olesen wrote:

>Hi
>
>In MSSQL one can use the @@RowCount system value, that holds :
>
>--MSSQL help--
>Returns the number of rows affected by the last statement
>--MSSQL help--
>
>What is the closest equiv. in FB 1.5 ?
>
>More specifically : I want to optimize the translation of this in
>general :
>(MSSQL)
><select query>
>if @@ROWCOUNT = 0 then <do_something_rescue>
>
>..without doing the trivial ineff. rewrite :
>(FB)
>(select count(*) <same select's FROM+WHERE part, FB flavoured>)
>into :tmp;
>if(:tmp = 0) then <do_something_rescue>
>else
><select query, FB flavoured>;
>
>tia.
>/Rasmus
>
>
Rasmus,

Take a look on page 22 of Firebird 1.5 Release notes, here an excerpt:

ROW_COUNT
Returns an integer, the number of rows affected by the last DML
statement. Available in PSQL, in the
context of the procedure or trigger module. Currently returns zero from
a SELECT statement.

Syntax
ROW_COUNT

Example
UPDATE TABLE1 SET FIELD1 = 0 WHERE ID = :ID;
IF (ROW_COUNT = 0) THEN
INSERT INTO TABLE1 (ID, FIELD1) VALUES (:ID, 0);

see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br