当前位置:网站首页>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 (* ̄︶ ̄)
边栏推荐
- About the swoole coroutine container
- Audio basics and PCM to WAV
- Doris 运维中遇到的问题
- Kotlin null pointer bug
- Uniapp -- the use of document collation and push of unipush
- STEP7主站与远程I/O组网_过路老熊_新浪博客
- Wireshark对IMAP抓包分析
- [转载]RSLOGIX 5000实例教程
- Stream in PHP socket communication_ Understanding of select method
- Leetcode-1528- rearrange string - hash table - string
猜你喜欢
Kylin
YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21
Let's talk about string today
兆欧表电压档位选择_过路老熊_新浪博客
Database - mongodb
How does excel translate Chinese words into English automatically? This formula teaches you
6.常用指令(上)v-cloak,v-once,v-pre
C ++ 引用与指针总结
Audio basics and PCM to WAV
js实现输入开始时间和结束时间,输出其中包含多少个季,并且把对应年月打印出来
随机推荐
Gradle的环境安装与配置
Let's talk about string today
Talk about the copy on write mechanism of PHP variables or parameters
js实现输入开始时间和结束时间,输出其中包含多少个季,并且把对应年月打印出来
MySQL version upgrade + data migration
解析产品开发失败的5个根本原因
IDEA中如何生成get/set方法
Leetcode-1528- rearrange string - hash table - string
记录一下刷LeetCode瞬间有思路的一道简单题——剑指 Offer 09. 用两个栈实现队列
mysql
达梦数据库修改字段信息采坑记
Kylin
JS中常用知识点
Talk about how to hot restart a spoole or PHP cli process
Linking MySQL database with visual studio2015 under win10
数组常用的一些操作方法
Talk about singleton mode!
对象数组去重
兆欧表电压档位选择_过路老熊_新浪博客
Uniapp -- list page of multi header tabs