创建触发器时出现 PLS-00049: 错误的赋值变量 ':NEW.land_name'

来源:互联网 发布:c语言选择排序算法 编辑:程序博客网 时间:2024/06/05 07:51

create or replace trigger t_hang_info
before insert or update or delete on hang_info
for each row
declare
    pbCount number;
begin
    select count(LANDID) into pbCount from TRADECENTER_LANDHANG where LANDID = :new.land_no;
    if inserting or updating then
        if pbCount<=0 then
            insert into TRADECENTER_LANDHANG (
            INFORID,
            LANDID,
            LANDNAME,
            STARTTIME,
            ENDTIME,
            HIGHESTPRICE,
            INCPRICE
            ) values (
            :new.hang_no,
            :new.land_no,
            :new.land_name,
            :new.hang_start_date,
            :new.hang_end_date,           
            :new.hang_start_price,
            :new.hang_inc_price           
            );
        else
            update TRADECENTER_LANDHANG set
            INFORID = :new.hang_no,
            LANDID = :new.land_no,
            LANDNAME = :new.land_name,
            STARTTIME = :new.hang_start_date,
            ENDTIME = :new.hang_end_date,
            --HIGHESTPRICE = :new.hang_start_price,
            INCPRICE = :new.hang_inc_price
            where landid = :new.land_no;
        end if;
    end if;
    if deleting then
      delete from TRADECENTER_LANDHANG where landid = :old.land_no;
    end if;
end;

两个带颜色的地方报错

PLS-00049: 错误的赋值变量 ':new.land_name'

PLS-00049: 错误的赋值变量 ':new.land_name'

检查表结构后发现是我已经把land_name字段总表hang_info中删除了,所以造成这样的错误,加上之后就测试通过了。

原创粉丝点击