面临以下错误:
[Error] PLS-00049 (12: 11): PLS-00049: bad bind variable 'NEW.OPTION_D'
我正在尝试执行以下操作:
create or replace trigger check_option_for_stage
before insert on lot_option
for each row
when (new.stage_id > 0 and new.option_id > 0)
declare
not_existing_option exception;
num_count number;
begin
select count(*) into num_count
from option_cost os
where :new.option_id = os.option_id and :new.stage_id = os.stage_id;
if num_count = 1 then
DBMS_OUTPUT.PUT_LINE('The option can be applied to the lot at the current stage');
ELSE
raise not_existing_option;
end if;
exception
when not_existing_option then
DBMS_OUTPUT.PUT_LINE('The option is not available on this stage, therefore rejected');
when others then
DBMS_OUTPUT.PUT_LINE('Oops!, something went wrong, it needs your attention!');
end;
/
我为什么要面对这个?为什么它是一个糟糕的绑定变量?我知道我应该能够通过键入来访问新值:new.whateverthecolumnname
我正在使用 Oracle 11g。
我正在玩的桌子的定义
SQL> desc option_cost
Name Null? Type
----------------------------------------- -------- ----------------------------
COST NOT NULL NUMBER
OPTION_ID NOT NULL NUMBER(38)
STAGE_ID NOT NULL NUMBER(38)
SQL> desc lot_option;
Name Null? Type
----------------------------------------- -------- ----------------------------
LOT_ID NOT NULL NUMBER(38)
OPTION_ID NOT NULL NUMBER(38)
COST NOT NULL NUMBER
DATE_CREATED DATE
STAGE_ID NOT NULL NUMBER(38)