If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
CREATE TRIGGER BOB.ADJUST4 AFTER INSERT ON BOB.ADJUST FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
update on_hand set on_hand.qty = on_hand.qty - ( Select a.qty from adjust a, on_hand o where a.part = o.part);
END
In the mean time I will look at the link you supplied
and see if that shades some light on my issue.
------------Thanks ----------
BJ
You need a where clause in your trigger to specify which row(s) in the on_hand table you want to update, ie the row that corresponds to the ADJUST item that the trigger is firing for.
It will probably be similar to the where clause you are using to select the qty in the subselect you have.
Something like:
CREATE TRIGGER BOB.ADJUST4 AFTER INSERT ON BOB.ADJUST FOR EACH ROW
REFERENCING NEW as INSERTED
MODE DB2SQL
BEGIN ATOMIC
update on_hand set on_hand.qty = on_hand.qty - ( Select a.qty from adjust a, on_hand o where a.part = o.part)
WHERE INSERTED.part = on_hand.part
END
I ran the code you supplied in pane # 4
including the referencing statement and it seems to
function perfectly !!
I have been looking for this solution for some time.
-----------Thanks very much -------------
BJ