Subject | RE: [firebird-support] Trigger Help |
---|---|
Author | Alan McDonald |
Post date | 2003-12-17T02:54:49Z |
> Hello all,you should always check for NULLs in this context - your statement
>
> I am using the following trigger to update a value in the "Orders" table
> and the "Stations" table in my database. I know that it appears not to
> be multi user safe, but rules in the client app prevent any two person
> from being logged onto a particular "Station" which provides the
> "StationID" field below. The problem is that the trigger does not seem
> to be firing.
>
> CREATE TRIGGER INSERTEXTORDERID FOR ORDERS
> ACTIVE BEFORE INSERT POSITION 0
> AS
> DECLARE VARIABLE UseID SmallInt;
> DECLARE VARIABLE LastExtOrderID Integer;
> BEGIN
> Begin
> SELECT UseExtOrderID, ExtOrderID
> FROM STATIONS
> WHERE STationID = NEW.StationID
> INTO :UseID, :LastExtOrderID;
> If (:UseID = 1) THEN
> begin
> New.ExtOrderID = :LastExtOrderID + 1;
> UPDATE Stations SET Stations.ExtOrderID =
>
>
> Stations.ExtOrderID + 1 WHERE Stations.StationID = New.StationID;
> end
> end
>
> END
> --
>
> Warm Regards,
>
> Lee
> SELECT UseExtOrderID, ExtOrderIDcan return NULLs and the test you have will never fire as you expect
Alan