Subject | Re: [firebird-support] Getting number of records affected ... |
---|---|
Author | Lucas Franzen |
Post date | 2003-12-17T12:45:56Z |
Anand,
Anand schrieb:
Example:
UPDATE MYTABLE SET MYFIELD = 0 WHERE MYCONSITION = 'Blabla'
IF ( ROW_COUNT ) = 0 THEN
BEGIN
INSERT INTO MYTABLE ...
END
If you use FB prior to 1.5 you can do sth. like:
...
declare variable IS_RECORD_THERE integer;
...
SELECT 0 FROM RDB$DATABASE
WHERE NOT EXISTS ( <update_condition> )
INTO :IS_RECORD_THERE;
IF ( IS_RECORD_THERE = 0 ) THEN
BEGIN
/* do your insert */
END
Luc.
Anand schrieb:
> I am trying to write a stored procedure that will attempt anwith FB1.5 you can use ROW_COUNT,
> Update ...
> statement first. Then it should check for the number of records
> affected by
> the Update statement, and if the number of records affected are
> zero, it
> should issue an Insert... statement.
> How do I find out the number of records affected by an action
> query?
Example:
UPDATE MYTABLE SET MYFIELD = 0 WHERE MYCONSITION = 'Blabla'
IF ( ROW_COUNT ) = 0 THEN
BEGIN
INSERT INTO MYTABLE ...
END
If you use FB prior to 1.5 you can do sth. like:
...
declare variable IS_RECORD_THERE integer;
...
SELECT 0 FROM RDB$DATABASE
WHERE NOT EXISTS ( <update_condition> )
INTO :IS_RECORD_THERE;
IF ( IS_RECORD_THERE = 0 ) THEN
BEGIN
/* do your insert */
END
Luc.