CREATE OR REPLACE TRIGGER sales_trig1
before insert on Inventory1
for each row
DECLARE
q Inventory1.qty%type;
id Inventory1.item_id%type;
si Sales.sitem_id%type;
tid Sales.trans_id%type;
td Sales.trans_dt%type;
tq Sales.trans_qty%type;
BEGIN
tid:='t_id111';
si:='&si';
tq:=&tq;
select item_id,qty
into id,q
from Inventory1
where id=si;
IF tq<=q THEN
insert into Sales
values(tid,si,date,tq);
q:=q-tq;
END IF;
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('EXCEPTION: Invalid item_id');
END;
错误如下
Errors for TRIGGER SALES_TRIG1: - LINE/COL ERROR -------- ----------------------------------------------------------------- 17/1 PL/SQL: SQL Statement ignored 17/33 PL/SQL: ORA-00936: missing expression