我有这些错误 - PLS-00679:在语句前/后部分中不允许触发绑定 PLS-00201:必须声明标识符“DBMS_OUT.PUT_LINE” - 但无法找到问题。 这些是涉及的脚本 -
create or replace trigger hiTk
for insert or update on lending
COMPOUND TRIGGER
--declare
L_Date date;
subtype copy_booksRec is lending%ROWTYPE;
type copied_bks is table of copy_booksRec;
cbks copied_bks := copied_bks();
before each row is
begin
cbks.extend;
cbks(cbks.last).cb_num := :new.cb_num;
cbks(cbks.last).sb_num := :new.sb_num;
-- cbks.last(i).date_L := :new.date_L;
end before each row;
before statement is
begin
for i in cbks.first .. cbks.last loop
select count(date_L) into L_Date from lending where sb_num = cbks(i).sb_num and date_L = :new.date_L;
if (Sysdate = :new.date_L) then
dbms_out.put_line('You can only make ONE LOAN at a time! You have already loaned a book on ' || L_Date);
else
cbks.delete;
end if;
end loop;
FORALL i IN cbks.first .. cbks.last
insert into lending values cbks(i);
cbks.delete;
end before statement;
end hiTk;
/
show errors
答案 0 :(得分:3)
这两个错误都准确地告诉你出了什么问题:
但你有:
before statement is
begin
for i in cbks.first .. cbks.last loop
select count(date_L) into L_Date from lending where sb_num = cbks(i).sb_num
and date_L = :new.date_L;
-- ^^^^ THIS IS A TRIGGER BIND, NOT ALLOWED IN BEFORE STATEMENT
没有提供名为DBMS_OUT
的软件包,它名为DBMS_OUTPUT
。