我要实习的功能是当一张table中插入一条id的记录之后用一个触发器把id对应的详细信息从别的table中插入到插入id的table中
,我自己写了个trigger,没有成功,高手指点一下:
create or replace trigger Test
after insert on test
for each row
declare -- local variables herebegin
update test set(test.test_id,test.name,test.email,test.phone)= (select t.test_id,t.name,t.email,t.phone from sourcetable t where t.test_id=:new test.test_id )
end Test Insert;
,我自己写了个trigger,没有成功,高手指点一下:
create or replace trigger Test
after insert on test
for each row
declare -- local variables herebegin
update test set(test.test_id,test.name,test.email,test.phone)= (select t.test_id,t.name,t.email,t.phone from sourcetable t where t.test_id=:new test.test_id )
end Test Insert;
before insert on test
for each row
begin
select t.name, t.email, t.phone
into :new.name, :new.email, :new.phone
from sourcetable t
where t.test_id = :new test.test_id;
end Test;
TRIGGER SCOTT.TEST 编译错误错误:PLS-00049: 错误的赋值变量 'NEW'
行:8
文本:where t.test_id =:new test.test_id;错误:PL/SQL: ORA-00933: SQL 命令未正确结束
行:8
文本:where t.test_id =:new test.test_id;错误:PL/SQL: SQL Statement ignored
行:5
文本:select t.name, t.email, t.phone
测试通过!create or replace trigger Test
before insert on test1
for each row
begin
select t.name, t.email, t.phone
into :new.name, :new.email, :new.phone
from sourcetable t
where t.test_id = :new test1.test_id;
end Test1;
before insert on test
for each row
begin
select t.name, t.email, t.phone
into :new.name, :new.email, :new.phone
from sourcetable t
where t.test_id = :new.test_id;
end Test;
自己也检查下吗。我替换过去写错了点