2014-12-01 34 views
0

嘿傢伙我試圖做一個觸發器來更新視頻表。我剛開始在課堂上學習觸發器,對於這個對我來說很裸露的人,我很新。我得到了這一點,通過谷歌和其他任何東西,但似乎無法找到所有這些錯誤的答案任何幫助或建議將不勝感激。這是帶有錯誤的觸發器。這些觸發錯誤意味着什麼

CREATE or REPLACE Trigger Available_Rule 

BEFORE INSERT ON Transaction 
FOR EACH ROW 

BEGIN 
SELECT (*) 
FROM Video, Transaction 
WHERE Status = :new.Status; 

IF :new.Date_Rented_Out is not null AND IF :new.Date_Returned = NULL 
THEN 
    UPDATE Video 
    set Status = Unavailable 
    where Status = :new.Status; 
End IF; 
END; 
/
show errors; 

2/1 PL/SQL: SQL Statement ignored 
2/9 PL/SQL: ORA-00936: missing expression 
4/16 PLS-00049: bad bind variable 'NEW.STATUS' 
6/42 PLS-00103: Encountered the symbol "IF" when expecting one of the following: (- + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg coun t current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal w ith character set specification> <a number> <a single-quoted S QL string> pipe <an alternatively-quoted string literal with c haracter set specification> <an alternatively-quoted 
10/19 PLS-00049: bad bind variable 'NEW.STATUS' 
12/5 PLS-00103: Encountered the symbol "end-of-file" when expecting on e of the following: end not pragma final instantiable order o verriding static member constructor map 
+0

你只需要一個IF..IF X和Y的話.. – Mihai 2014-12-01 21:26:51

+0

謝謝!!!!!! – Erica 2014-12-01 21:32:30

+0

也使用單引號不可用'set Status ='Unavailable'' – Mihai 2014-12-01 21:41:09

回答

1

改變這一點:

IF :new.Date_Rented_Out is not null AND IF :new.Date_Returned = NULL 

這樣:

IF :new.Date_Rented_Out is not null AND :new.Date_Returned is NULL 

失去= NULL和額外的IF

+0

是的工作謝謝你! – Erica 2014-12-01 21:33:44

相關問題