大家好,又见面了,我是你们的朋友全栈君。
1、declare 声明变量后的每个变量都要加分号; 2、所有的语句结束和sql语句结尾,都要加分号; 3、变量赋值 variable :=’1234′ 如:recordId := ‘1234’; 4、插入列数据获取 :new.colname 如:new.exec_record_id 5、sql查询写入变量 select colname into variable 如: select verify_date into execDate from orders_executed_record where record_id=’1234′;
触发器举例:
CREATE OR REPLACE TRIGGER "TR_NUTRITION"
after update on inp_bill_detail
for each row
declare
myexp exception;
execDate date;
recordId varchar2(30);
begin
recordId :=:new.exec_record_id;
if :new.exec_record_id is not null then
select nvl(oen.verify_date,oer.execute_date_time) into execDate
from orders_executed_record oer left join orders_executed_nutrition oen on oer.record_id=oen.record_id
where oer.record_id = recordId ;
if execDate is not null then
raise myexp;
end if;
end if;
exception
when myexp then raise_application_error('-20002', '计费后,执行(核对)日期不能为空,计费ID=' || :new.detail_no || ' 执行ID=' || recordId);
end ;
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/159865.html原文链接:https://javaforall.cn