Subject Re: before insert trigger
Author Duleep
Hello

Here is goes..

This code had to be re generated thrice during the last six months.

SET TERM ^ ;

ALTER TRIGGER DBTRINSERTRETURN
ACTIVE BEFORE INSERT POSITION 0
AS
DECLARE VARIABLE MAXVALUE SMALLINT;
BEGIN
IF (EXISTS(SELECT SERIALNUMBER FROM SALESRETURNDETAILS WHERE
SALESRETURNNUMBER = NEW.SALESRETURNNUMBER) )THEN
SELECT MAX(SERIALNUMBER) FROM SALESRETURNDETAILS WHERE
SALESRETURNNUMBER = NEW.SALESRETURNNUMBER INTO :MAXVALUE;
ELSE
MAXVALUE = 0;
NEW.SERIALNUMBER = MAXVALUE + 1;
END

^

SET TERM ; ^

Regards
Duleep


--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 12:28 PM 3/08/2004 +0000, you wrote:
> >Hello Everyone
> >
> >I use firebird 0.9x ss on Redhat 7.2
> >
> >There is a before insert trigger which I use to update a particular
> >serial number and returns a value. At times it returns a null value
> >and I am forced to drop and recreate the trigger to get it working.
> >
> >any clues ?
>
> Triggers can't return values. So show us your trigger and explain
what you
> are expecting.
>
> /heLen