sybase触发器移植到oracle时出错,各位帮忙~~
现有sybase的触发器如下:
create trigger tri_byq_userfiles on V_Y_YXBYQ
for insert as
declare getUserInfo cursor for
select BYQBH from inserted
for read only
declare @user_no varchar(20)
open getUserInfo
fetch getUserInfo into @user_no
while @@sqlstatus != 2
begin
......(该处省略)
fetch getUserInfo into @user_no
end
close getUserInfo
deallocate cursor getUserInfo
要将上面的触发器移植到oracle里,我把它改造成了下面这样:
create trigger tri_byq_userfiles
after insert
on V_Y_YXBYQ
for each row
declare
user_no varchar2(20);
cursor getUserInfo is
:new.BYQBH;
begin
open getUserInfo;
fetch getUserInfo into user_no;
while getUserInfo%found loop
begin
......(省略)
fetch getUserInfo into user_no;
end;
end loop;
close getUserInfo;
end;
运行后报错,问题是出在游标的定义上,具体的是:new.BYQBH这里出错。sybase数据库的select BYQBH from inserted在oracle里面不就是:new.BYQBH吗?如果这里不应该这样写的话那应该改成什么呢?已经被这个问题困惑很久了,各位高手请帮忙~~~
------解决方案--------------------oracle中触发器改写为行级触发器,不需要再定义cursor了。