我有以下触发器:
create or replace
trigger updateBeds
After insert or update on INPATIENT_STAY for
each row
Begin
if(:new.INPATIENT_STAY.DATEPLACEDINWARD<=sysdate and :new.INPATIENT_STAY.expectedleavedate>=sysdate)
then
update WARD
set BEDSAVAIL = TOTALBEDS - 1
where WARDNUM = :new.INPATIENT_STAY.WARDNUM;
end if;
if(:new.INPATIENT_STAY.DATELEFT <= sysdate) then
update WARD
set BEDSAVAIL = TOTALBEDS +1
where WARDNUM = :new.INPATIENT_STAY.WARDNUM;
end if;
END;
totalbeds
如果INPATIENT_STAY.DATEPLACEDINWARD
和INPATIENT_STAY.expectedleavedate
小于系统日期,则此触发器旨在从列中减去 1 。此外,如果INPATIENT_STAY.DATELEFT
小于或等于系统日期,totalbeds
则应增加 1。
通过调用的外键WARD
链接到INPATIENT_STAY
INPATIENT_STAY
WARDNUM
当我尝试编译触发器时,出现以下错误:
Error(2,4): PLS-00049: bad bind variable 'NEW.INPATIENT_STAY'
Error(2,54): PLS-00049: bad bind variable 'NEW.INPATIENT_STAY'
Error(6,21): PLS-00049: bad bind variable 'NEW.INPATIENT_STAY'
Error(8,4): PLS-00049: bad bind variable 'NEW.INPATIENT_STAY'
Error(11,21): PLS-00049: bad bind variable 'NEW.INPATIENT_STAY'
我不确定我在这里做错了什么。任何帮助深表感谢
这些表是:
WARD
WARDNUM VARCHAR2(20 BYTE)
NAME VARCHAR2(40 BYTE)
TOTALBEDS NUMBER
BEDSAVAIL NUMBER
INPATIENT_STAY
INPATIENTID VARCHAR2(20 BYTE)
WARDNUM VARCHAR2(20 BYTE)
EXPECTEDLEAVEDATE DATE
DATEPLACEDINWARD DATE
DATELEFT DATE