当前位置:网站首页>Oracle writes a trigger that inserts a piece of data first and updates a field in the data
Oracle writes a trigger that inserts a piece of data first and updates a field in the data
2022-06-25 23:53:00 【langmeng110】
The trigger has just been used recently , In principle, it should be updated after insertion , I thought it was written in the following way , I also found many methods on the Internet , The results are not quite right . The fields that need to be updated have not been updated at all , I think it should be a logical problem :
create or replace trigger UPDATE_REDLIST_TYPE
after insert on redlist_pass_person
for each row
declare
-- local variables here
redlist_flag varchar2(10);
begin
select (case
when count(1) > 0 then
'1'
else
'0'
end)
into redlist_flag
from redlist_person t1
where t1.redlist_card_no = :new.card_no;
update redlist_pass_person set redlist_type=redlist_flag where :old.id = :new.id;
end UPDATE_REDLIST_TYPE;
Found behind , It needs to be written like this :
create or replace trigger UPDATE_REDLIST_TYPE
before insert on redlist_pass_person
for each row
declare
-- local variables here
redlist_flag varchar2(10);
begin
select (case
when count(1) > 0 then
'1'
else
'0'
end)
into redlist_flag
from redlist_person t1
where t1.redlist_card_no = :new.card_no;
:new.redlist_type := redlist_flag;
end UPDATE_REDLIST_TYPE;
therefore , Write this down , And let more friends not waste a lot of time on this little problem ...
Just like what you like (* ̄︶ ̄)
边栏推荐
猜你喜欢
随机推荐
Using Google protobuf protocol environment configuration in PHP
聊聊swoole或者php cli 进程如何热重启
keil编译运行错误,缺少error:#5:#includecore_cm3.h_过路老熊_新浪博客
php中使用Makefile编译protobuf协议文件
How does excel translate Chinese words into English automatically? This formula teaches you
SSM integrated learning notes (mainly ideas)
对伪类的理解
c_ uart_ interface_ Example and offboard modes
proxy
Line height for small use
寻找翻转数组的最小值[抽象二分]
实例:用C#.NET手把手教你做微信公众号开发(21)--使用微信支付线上收款:H5方式
二叉排序树
Px4 multi computer simulation (gazebo)
Leetcode 513. 找树左下角的值
IDEA中如何生成get/set方法
C# IO Stream 流(二)扩展类_封装器
DPVS-FullNAT模式部署篇
谈一谈生产环境中swoole协程创建数量控制机制
mysql








