a.. Subject: Re: Prevent a record from being written using a trigger program.
b.. From: Booth Martin <booth@xxxxxxxxxxxx>
c.. Date: Fri, 02 Sep 2011 13:43:43 -0500
d.. List-archive: <
http://archive.midrange.com/rpg400-l>
e.. List-help: <mailto:rpg400-l-request@xxxxxxxxxxxx?subject=help>
f.. List-id: RPG programming on the IBM i / System i <rpg400-l.midrange.com>
g.. List-post: <mailto:rpg400-l@xxxxxxxxxxxx>
h.. List-subscribe: <
http://lists.midrange.com/mailman/listinfo/rpg400-l>, <mailto:rpg400-l-request@xxxxxxxxxxxx?subject=subscribe>
i.. List-unsubscribe: <
http://lists.midrange.com/mailman/listinfo/rpg400-l>, <mailto:rpg400-l-request@xxxxxxxxxxxx?subject=unsubscribe>
--------------------------------------------------------------------------------
I have no desire to beat on a dead horse, but if you are going to be sending messages anyway, why not just pop-up a window saying "The new customer number is: "12345" " when they click the add button. The new customer number is assigned quickly by the trigger program, so no user delay will be experienced.
(My fear is that if your trigger chases down all the child files that can be affected today, that design would fail tomorrow when the gunslinger from out of town adds a new child file and doesn't know he is supposed to tell you about it.)
*****
sending an escape message up the call stack is very diffrent to sending a message to a user!
If you send an escape message from a before trigger, the write will fail and the programm, which caused the trigger to fire will have an error situation (using SQL a negative SqlCode, using RLA the error indicator of the write operation, if there is one coded, wil be set on). In this case the record will not be written/updated to the database.
That's very diffrent from deleting the record in an after trigger!!! preventing the update in a before trigger, the programm trying it, will get knowledge. Deleting the record in an after trigger for the originating programm it looks like all did work; I would strongly recommend not to use an after trigger to delete records!
D*B
As an Amazon Associate we earn from qualifying purchases.