您的位置:首页 > 数据库 > Oracle

oracle For循环和触发器Tigger

2016-04-05 16:57 465 查看
--循环

begin

for cycle in (select id, testcycle from specialpapers) loop

if (cycle.testcycle is null) then

update specialpapers set testcycle = 48 where id = cycle.id;

end if;

end loop;

end;

for循环,是一种隐式游标,效率比较高,编写使用方便。

--触发器

create or replace trigger test

before insert or update on specialpapers

for each row

declare

-- local variables here

begin

if :NEW.Testcycle is null then

:NEW.Testcycle := 48;

end if;

end test;

--删除触发器

DROP TRIGGER test;

--授权用户 调试权限

GRANT debug any procedure, debug connect session TO username
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: