开发者

create trigger with ' insert into.. select...' statement

I am writing an after insert trigger which inserts data to list_of_requests table taking the data from emp_sup table.

create trigger trig_lor
after insert 
on employee_skillset
for each row begin
    insert into list_of_requests (APPROVER1,A开发者_如何转开发PPROVER2,LOGDATE) 
    select sup1,sup2,'#dateFormat(now(),"yyyy/mm/dd")#' from empsup
        where empno=NEW.employee_number
end

This is giving error as: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'trigger trig_lor after insert on employee_skillset for each row begin inse' at line 1

How do I make this work?


Not tested but give it a try.

delimiter //
drop trigger if exists trig_lor //
create trigger trig_lor
after insert 
on employee_skillset
for each row
begin
insert into list_of_requests (APPROVER1,APPROVER2,LOGDATE) 
select sup1,sup2,curdate() from empsup where empno=NEW.employee_number;
end; //
delimiter ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜