我是新來的SQL,我試圖創建一個插入到審計表的觸發器。Oracle觸發無效
create or replace trigger late_ship_insert
after insert on suborder
for each row
declare
employee int;
begin
select emp_id
into employee
from handles
where order_no = :new.order_no;
if :new.actual_ship_date > :new.req_ship_date then
insert into ship_audit
values (employee, :new.order_no, :new.suborder_no, :new.req_ship_date, :new.actual_ship_date);
end;
錯誤:
Warning: execution completed with warning
trigger late_ship_insert Compiled.
但是,一旦我嘗試的INSERT語句它告訴我,觸發沒有工作,那麼放棄它。
Error starting at line 1 in command:
insert into suborder
values (8, 3, '10-jun-2012', '12-jul-2012', 'CVS', 3)
Error at Command Line:1 Column:12
Error report:
SQL Error: ORA-04098: trigger 'COMPANY.LATE_SHIP_INSERT' is invalid and failed re-validation
04098. 00000 - "trigger '%s.%s' is invalid and failed re-validation"
*Cause: A trigger was attempted to be retrieved for execution and was
found to be invalid. This also means that compilation/authorization
failed for the trigger.
*Action: Options are to resolve the compilation/authorization errors,
disable the trigger, or drop the trigger.
任何想法是什麼導致這一點,任何幫助將不勝感激。謝謝!
做一個'SHOW ERRORS'創建觸發器和告訴我們錯誤消息後。 – 2012-07-19 20:51:37
我會驚訝地發現Oracle中的int類型...嘗試編號? – 2012-07-19 20:52:06
我認爲你錯過了'END IF;'plus,我認爲所有的'聲明'變量都應該放在開頭。 – alfasin 2012-07-19 20:55:40