【发布时间】:2020-10-06 19:57:10
【问题描述】:
我有两张表,seat_allocation 和 program_code。我想创建一个触发器来检查座位分配中的条目数是否等于该 prog_code(programm_code 表中的列)的 max_seats(programm_code 表中的列)。这是我的代码:
SQL> create or replace trigger seats_full
2 before insert on seat_allocation
3 for each row
4 declare
5 cnt programme_code.max_seats%type;
6 max programme_code.max_seats%type;
7 begin
8 select count(*) into cnt from seat_allocation where prog_code=(select prog_code from programme_code where prog_code = :NEW.prog_code);
9 select max_seats into max from programme_code where prog_code=(select prog_code from programme_code where prog_code = :NEW.prog_code);
10 if max=cnt then
11 RAISE_APPLICATION_ERROR(-21000,'No vacant seats available');
12 end if;
13 end;
14 /
它给出警告:使用编译错误创建的触发器。你能帮我找出问题所在吗?
【问题讨论】:
-
一个有用的提示:如果你打算从命令行编译代码,在你编译一个对象之后,如果它有错误,你可以使用
show errors;命令查看导致该对象的错误编译失败。