below I have added the trigger that I created. Everything is working fine except the table is not updated. What I think is happening is the table has not created the record the trigger is trying to update. If i use the same trigger and hard code the apkey # it works fine. But when I use the variable it does not work. The variable is paasing ok because what I had the query do was update the field in the database with the apkey.....i just hardcoded the record to add it to. I think there seems to be a sequence problem here....what is it that gets executed first? Does the add to the table actually complete before the trigger runs?
Some back ground info on this is the following. I have 2 tables
1. aplic
2. cobco
both are linked via apkey
all i want to do is update a field on the cobco table when a record is added to the aplic table. there are always matching records linked for these two tables.....please help!!!
CREATE PROCEDURE buff_licno7 (pakey INTEGER )
DEFINE nexno integer;
DEFINE lkey INTEGER;
LET nexno = (SELECT nextvalu from buff_seq1);
let lkey = pakey;
UPDATE cobcoo
SET trcerti = nexno where apkey = lkey;
update buff_seq1 set nextvalu = nextvalu +1;
END PROCEDURE;
CREATE TRIGGER licno_trig
INSERT ON aplic
REFERENCING NEW AS new_licno
FOR EACH ROW WHEN(new_licno.apdefnkey = 1043 )
(EXECUTE PROCEDURE buff_licno7(new_licno.apkey ));
Some back ground info on this is the following. I have 2 tables
1. aplic
2. cobco
both are linked via apkey
all i want to do is update a field on the cobco table when a record is added to the aplic table. there are always matching records linked for these two tables.....please help!!!
CREATE PROCEDURE buff_licno7 (pakey INTEGER )
DEFINE nexno integer;
DEFINE lkey INTEGER;
LET nexno = (SELECT nextvalu from buff_seq1);
let lkey = pakey;
UPDATE cobcoo
SET trcerti = nexno where apkey = lkey;
update buff_seq1 set nextvalu = nextvalu +1;
END PROCEDURE;
CREATE TRIGGER licno_trig
INSERT ON aplic
REFERENCING NEW AS new_licno
FOR EACH ROW WHEN(new_licno.apdefnkey = 1043 )
(EXECUTE PROCEDURE buff_licno7(new_licno.apkey ));