当前位置:网站首页>oracle写一个先插入一条数据,在将该数据中一个字段更新的触发器的坑
oracle写一个先插入一条数据,在将该数据中一个字段更新的触发器的坑
2022-06-25 22:06:00 【langmeng110】
最近刚用使用触发器,原理上应该是在插入之后再更新,原本以为是以下这种写法,在网上也找了很多方法,结果说的都不太对.需要更新的字段根本没有被更新,我想应该是逻辑上的问题:
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;
后面发现,是需要这样写:
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;
所以,把这个记录下来,也让更多朋友不要在这个小问题上浪费很多时间...
喜欢的就随手点个赞吧(* ̄︶ ̄)
边栏推荐
- Analysis on the control condition and mode of go cooperation overtime exit
- DPVS-FullNAT模式keepalived篇
- Reprint: detailed explanation of qtablewidget (style, right-click menu, header collapse, multiple selection, etc.)
- Architecture part -- the use of UMI framework and DVA
- 登录拦截器
- 关于Swoole协程容器
- Use of xinchida ble 5.0 Low Power Bluetooth module (at command serial port transparent transmission) rsbrs02abr
- DPVS-FullNAT模式部署篇
- CSDN添加页内跳转和页外指定段落跳转
- xtrabackup的备份还原
猜你喜欢

Uniapp -- the use of document collation and push of unipush

UE4 learning records create a role and control its movement

第五章 习题(124、678、15、19、22)【微机原理】【习题】

Kylin

YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21

史上最简单的录屏转gif小工具LICEcap,要求不高可以试试

提取系统apk

森林的先序和中序遍历

hiberate核心API/配置文件/一级缓存详解

二进制、16进制、大端小端
随机推荐
MySQL自定义函数实例
YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21
OpenResty篇01-入门简介和安装配置
Extraction system apk
C. Fibonacci Words-April Fools Day Contest 2021
idea 查看单元测试覆盖率
C. Planar Reflections-CodeCraft-21 and Codeforces Round #711 (Div. 2)
CSDN原力值
Analysis on the control condition and mode of go cooperation overtime exit
STL教程5-STL基本概念及String和vector使用
Customize the qcombobox drop-down box, right align the display, and slide the drop-down list
[Axi] interpretation of Axi protocol atomic access
对卡巴斯基发现的一个将shellcode写入evenlog的植入物的复现
(serial port Lora module) centrida rf-al42uh private protocol test at instruction test communication process
解决TypeError: Unicode-objects must be encoded before hashing
音频基础知识以及PCM转WAV
C# IO Stream 流(一)基础概念_基本定义
debezium
18亿像素火星全景超高清NASA放出,非常震撼
Uniapp - call payment function: Alipay