create table A
(
id int primary key ,
name varchar(100)
)create table B
(
id int primary key ,
name varchar(100)
)要求 当表A 插入一条数据的时候 表B通过触发器 自动插入一条数据。
例如 insert into A values(id,name) values(1,'zcq')
表B 插入的ID 和表A 一样
(
id int primary key ,
name varchar(100)
)create table B
(
id int primary key ,
name varchar(100)
)要求 当表A 插入一条数据的时候 表B通过触发器 自动插入一条数据。
例如 insert into A values(id,name) values(1,'zcq')
表B 插入的ID 和表A 一样
after insert on send
referencing new as old_value
for each row
declare
-- local variables here
begin insert into othertable values(:new_value.字段1,:new_value.字段2,....);
...
...end send_log;
create or replace trigger send_log
after insert on send
referencing new as new_value
for each row
declare
-- local variables here
begin insert into othertable values(:new_value.字段1,:new_value.字段2,....);
...
...end send_log;
after insert on A
referencing new as new_value
for each row
declare
-- local variables here
begin insert into B values(:new_value.id,:new_value.name);end tri_test;
create or replace trigger tri_a
after insert on A
REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
BEGIN
INSERT INTO B VALUES(:new.field1,:new.field2....);
end;
SQL State = 42000 SQL Code = 1064 SQL Message = 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 'end' at line 1 Exception message = java.sql.SQLException: 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 'end' at line 1
insert into A values(id,name) values(:new.id,:new.name)