我正在尝试使用触发器概念将值插入表中,但我收到的错误是我的代码
1 create or replace trigger trig_sub
2 before insert on subscription
3 for each row
4 declare
5 m purchases.msisdn%type;
6 c purchases.circleid%type;
7 con purchases.contentproviderid%type;
8 pac purchases.packagepriceoptionid%type;
9 p purchases.packageid%type;
10 o purchases.operatorid%type;
11 pt purchases.purchasetime%type;
12 mes purchases.messagestatus%type;
13 ts purchases.traiservicekey%type;
14 ubs number(5):=0;
15 sq number(5);
16 extm date;
17 cursor cur_pur is select msisdn,circleid,contentproviderid,packagepriceoptionid,packageid,
operatorid,purchasetime,messagestatus,traiservicekey from purchases where
eventype<>'Content Purchase' and status=1;
18 begin
19 select sub1.next,sysdate+5 into sq,extm from dual;
20 open cur_pur;
21 loop
22 fetch cur_pur into m,c,con,pac,p,o,pt,mes,ts;
23 exit when cur_pur%notfound;
24 if(m=old.msisdn) then
25 if(old.unsubscribdbyuser=1) then
26 insert into subscription(subscriptionid,packageid,subscriptiontime,xpirytime,
unsubscribedbyuser,remark,packagepriceid,operatorid,contentproviderid,circleid,
traiservicekey) values(sq,p,pt,extm,ubs,mes,pac,o,con,c,ts);
27 elsif(old.unsubscribdbyuser=0) then
28 update subscription set lastrenewaltime=sysdate and lastrenewalattempttime=sysdate and
expirytime=sysdate+5 and modifiedtime=sysdate;
29 end if;
30 else
31 insert into subscription(subscriptionid,packageid,subscriptiontime,xpirytime,
unsubscribedbyuser,remark,packagepriceid,operatorid,contentproviderid,circleid,
traiservicekey) values(sq,p,pt,extm,ubs,mes,pac,o,con,c,ts);
32 end if;
33 end loop;
34 close cur_pur;
35 end trig_sub;
36 /
这是错误:
使用编译器错误创建的触发器。
显示错误触发trig_sub; 19/1 PL / SQL:忽略SQL语句 19/49 PL / SQL:ORA-00933:old.msisdn必须声明
任何人都可以告诉我为什么我面临这个错误,因为我是这个概念和技术的新手 任何帮助将不胜感激
答案 0 :(得分:3)
您将dml操作之前的行称为old
而不是:old
(注意冒号)。例如,第24-25行应为:
24 if(m=:old.msisdn) then
25 if(:old.unsubscribdbyuser=1) then