I have a table AAA with columns "a" character(6), "b" character (30),
and some others.
I have a table LLL with columns "a" character(6), "b" character (30)
When I insert into table AAA I do not know the value of column "b". I
need my insert trigger to lookup the record in LLL where LLL.a = AAA.a,
and insert the corresponding value from LLL.b into AAA.b
TIA :-)
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Philip Sherman
Art S. Kagel
create trigger AAA_ins_trg
on AAA for insert as
update AAA
set bbb = L.bbb
from AAA A,
LLL L
where A.aaa = L.aaa
return
CREATE TRIGGER AAA_ins_trg
AFTER INSERT ON AAA FOR EACH STATEMENT
MERGE INTO AAA USING LLL L ON A.aaa = L.aaa
WHEN MATCHED THEN A.bbb = L.bbb
(Makes no sense to me....)
Could it be that LLL is the "INSERTED" table?
In this case:
CREATE TRIGGER AAA_ins_trg
BEFORE INSERT ON AAA REFERENCING NEW AS n FOR EACH ROW
SET n.bbb = .....
Cheers
Serge