Subject Re: [firebird-support] ...create trigger problem
Author Helen Borrie
At 12:32 PM 24/06/2004 +0200, you wrote:
>Hi firebird group,
>
>when i try to execute my sql file (definition of the file is below) i get
>this error:
>
>h-2.05b$ ./isql -u user -p pwd localhost:/var/firebird/test.fdb -i
>/Firebird_Trigger.sql
>Statement failed, SQLCODE = -104
>
>Dynamic SQL Error
>-SQL error code = -104
>-Token unknown - line 9, char 55
>-;
>Expected end of statement, encountered EOF
>
>
>
>Here is the Definiton of the Firebird_Trigger.sql file:
>
>SET TERM !! ;
>CREATE TRIGGER AUSLAGE_CHANGE FOR AUSLAGE
>ACTIVE
>AFTER DELETE OR UPDATE
>POSITION 0
>AS
>BEGIN
>SELECT * FROM WEITERVERARB WHERE AUSLAGE = OLD.NUMMER ;

You can't do this in PSQL - if you select, you have to put the returned
rows somewhere.

What you want is
IF (EXISTS(SELECT 1 FROM WEITERVERARB
WHERE AUSLAGE = OLD.NUMMER)) THEN

>/* REMOVE THIS ***********IF (sqlcode = 0) THEN *************** */
>exception auslage_nummer;
>END !!
>SET TERM ; !!

/heLen