create or replace trigger production_new_trigger
before insert on table_a
for each row
declare
cursor cursor_table_b is select t.a,t.b,t.c from table_b t where t.c = 123;
cur_table_b_type cursor_table_b%rowtype;
begin
open cursor_table_b;
-- 这个地方开始出问题.用while loop来循环的时候,一行都没插入.
--但因为用loop循环的话最后会多出一行重复记录,这是loop先执行后判断照成的,所以不能用loop.
--loop
while cursor_table_b%found loop
fetch cursor_table_b into cur_table_b_type;
insert into table_c values (cur_table_b_type.a,cur_table_b_type.b,cur_table_b_type.c)
end loop;
--exit when cursor_table_b%notfound;
close cursor_table_b;
end;
--各位兄弟有知道原因的不吝赐教.
解决方案 »
- (转载)【独家连载】企业级GoldenGate实战揭秘(1)
- ?急!!关于oracle数据整合的一个问题,高手看看 谢谢
- 【急急急急急急问】Oracle 9i怎么备份?????
- oracle11g,我安装了透明网关后,原来PL/SQL都进不去了,说TNS无法解析指定的连接标识符
- oracle 存储过程插入数据的问题?
- oracle9i的问题(急)
- 求一update的触发器的标准例子,谢谢
- 请教关于oracle8I中从noarchive到archive时出现的问题???????????//
- Oracle中什么是RMAN , 举个例子。
- 请问谁写过OCI的程序,哪里有OCI的资料下载?请帮助我!
- 变量问题
- 新人问:oracle fundamental中的这句话该怎么理解?
这句后面有个; 手误没打上.
create or replace trigger production_new_trigger
before insert on table_a
for each row
declare
cursor cursor_table_b is select t.a,t.b,t.c from table_b t where t.c = 123;
cur_table_b_type cursor_table_b%rowtype;
begin
open cursor_table_b;
loop
fetch cursor_table_b into cur_table_b_type;
exit when cursor_table_b%notfound;
insert into table_c values (cur_table_b_type.a,cur_table_b_type.b,cur_table_b_type.c)
end loop;
close cursor_table_b;
end;
fetch cursor_table_b into cur_table_b_type;
insert into table_c values (cur_table_b_type.a,cur_table_b_type.b,cur_table_b_type.c)
end loop;
--exit when cursor_table_b%notfound;
close cursor_table_b;你还没fetch就用%found来判断了
改成
loop
fetch cursor_table_b into cur_table_b_type;
exit when cursor_table_b%notfound;
insert into table_c values (cur_table_b_type.a,cur_table_b_type.b,cur_table_b_type.c)
end loop;
close cursor_table_b;