Subject RE: [firebird-support] Trigger Help
Author Martin Dew
Lee

When I have a problem with a trigger and think it is not firing I tend
to write an exception into the database, and start adding exception
lines in the trigger, that way if the exception fires at one part but
not in another then you are not reaching that desired point in the
trigger. So it could actually be your if statement that is not working
the exact way you want it too..

Martin

-----Original Message-----
From: Lee Jenkins [mailto:lee@...]
Sent: 16 December 2003 16:39
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Trigger Help



Hello all,

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


To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com




Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/