I've written a trigger to insert a row into table b after an operation on table a. For some reason, it has no effect if I add this trigger 'after insert' and then insert a row. However, it does work if I add the trigger as 'after update', and update the row.
Here's the trigger code. When I replace 'AFTER UPDATE' with 'AFTER INSERT', and do an insert, then nothing happens when i insert a new row. I get no errors when creating the trigger, and I am not trying to update the same table the trigger is being set upon. Any help is appreciated! thanks, Jen
drop trigger if exists insertUndecided;
DELIMITER //
CREATE TRIGGER insertUndecided
AFTER UPDATE ON jiraissue
FOR EACH ROW
BEGIN
insert into nodeassociation (SOURCE_NODE_ID, SOURCE_NODE_ENTITY, SINK_NODE_ID, SINK_NODE_ENTITY, ASSOCIATION_TYPE, SEQUENCE)
select
NEW.id as SOURCE_NODE_ID,
'Issue' as SOURCE_NODE_ENTITY,
(select pv.id from projectversion pv
where pv.vname='undecided'
and pv.project=NEW.project ) as SINK_NODE_ID,
'Version' as SINK_NODE_ENTITY,
'IssueFixVersion' as ASSOCIATION_TYPE,
NULL as SEQUENCE
from dual where exists
(select pkey from jiraissue
where id=NEW.id and id not in
(select distinct source_node_id from nodeassociation
where source_node_entity='Issue' and SINK_NODE_ENTITY='Version'
and ASSOCIATION_TYPE='IssueFixVersion') );
END;//
DELIMITER ;