rem *****************************************************
rem ** 触发器
rem ** 功能:欲取款金额数大于账户余额,系统提示出错
rem ******************************************************
create or replace trigger WithdrawTri
before insert or update on Withdraw1416
declare
money Account1416.balance%type;
begin
select balance into money from Account1416 where accountNo1416 = :new.accountNo1416;
if money < :new.withdrawSum then
rasie_application_error(-20000,'您的当前的可用余额不足,请您重新确认取款额',);
end if;
end WithdrawTri;
如果插入withdraw1416(取款表)中的值withdrawSum大于Account1416(账户表)中的balance值,就提示出错,为什么不行呢
哪位好心人帮我改改!不胜感激!
Error report:
ORA-04082: NEW 或 OLD 引用不允许在表级触发器中04082. 00000 - "NEW or OLD references not allowed in table level triggers"
*Cause: The trigger is accessing "new" or "old" values in a table trigger.
*Action: Remove any new or old references.
rem ** 触发器
rem ** 功能:欲取款金额数大于账户余额,系统提示出错
rem ******************************************************
create or replace trigger WithdrawTri
before insert or update on Withdraw1416
declare
money Account1416.balance%type;
begin
select balance into money from Account1416 where accountNo1416 = :new.accountNo1416;
if money < :new.withdrawSum then
rasie_application_error(-20000,'您的当前的可用余额不足,请您重新确认取款额',);
end if;
end WithdrawTri;
如果插入withdraw1416(取款表)中的值withdrawSum大于Account1416(账户表)中的balance值,就提示出错,为什么不行呢
哪位好心人帮我改改!不胜感激!
Error report:
ORA-04082: NEW 或 OLD 引用不允许在表级触发器中04082. 00000 - "NEW or OLD references not allowed in table level triggers"
*Cause: The trigger is accessing "new" or "old" values in a table trigger.
*Action: Remove any new or old references.
解决方案 »
- 如何解决oracle 中文乱码
- 求sql语句:得出2009年所有周末的日期
- 求教~能不能在嵌套表中创建主键约束,unique,外键。
- Insert into message_m (site_cd,msg_seq_no,message,message_yobi,reg_day,trans_time,trans_kbn,trans_yobi1,trans_yobi2)
- 怎么从ORACLE中查到支持的最大连接数?
- 如何加快查询速度?急!
- 急!在線等﹒在Oracle中寫一個存儲過程返回一個數據集
- 我oracle进不处,假如要重新安装oracle,原来的数据库数据还在不在?
- ERwin中的内容如何导出成html格式?
- 查询的小问题
- 求助,这个触发器怎么了?
- 关于下面错误的解释
before insert or update on Withdraw1416
for each row--行级触发器
declare
money Account1416.balance%type;
begin
select balance into money from Account1416 where accountNo1416 = :new.accountNo1416;
if money < :new.withdrawSum then
rasie_application_error(-20000,'您的当前的可用余额不足,请您重新确认取款额',);
end if;
end WithdrawTri;
加上红色部分,使用行级触发器,即针对行的,
行级触发器才能使用:new.字段,:old.字段来引用字段的新值或旧值
没有for each row则是表级触发器
create or replace trigger WithdrawTri
before insert or update on Withdraw1416 for each row
declare
money Account1416.balance%type;
begin
select balance into money from Account1416 where accountNo1416 = :new.accountNo1416;
if money < :new.withdrawSum then
rasie_application_error(-20000,'您的当前的可用余额不足,请您重新确认取款额',);
end if;
end WithdrawTri;-- 应该搞行级触发器
6/38 PLS-00103:出现符号","在需要下列之一时:
>,*, & = - < / > at in is mod remainder not rem =>
<an exponent <**>> <> or! = or ~= >=
<= <> and or like like2 like4 likec as between from using || memeber submultiset
rasie_application_error(-20000,'您的当前的可用余额不足,请您重新确认取款额');
在PL/SQL中所有的标点符号都必须是英文下的标点符号