2010-06-04 84 views
0
CREATE TRIGGER Background_Process_Report_trit 
AFTER INSERT 
ON Background_Process_Report 
FOR EACH ROW 
IF INSERT(PROCESS_NAME) 
BEGIN 
    SET EXECUTION_TIMESTAMP := NEW.TIMESTAMP; 
END; 
/

process_name - 我的Background_Process_Report表中的列。但我想更新每次創建process_name(由java應用程序)時,觸發更新EXECUTION_TIMESTAMP表中的時間。 但它拋出compliation錯誤..如果在oracle觸發器創建中插入錯誤?

錯誤:

IF INSERT(PROCESS_NAME) 
* 
ERROR at line 5: 
ORA-04079: invalid trigger specification

如何reslove這個錯誤

+0

你想'IF INSERT(PROCESS_NAME)'做什麼? – 2010-06-04 10:49:14

回答

4

如果EXECUTION_TIMESTAMP是一個表像你說的,那麼它一定有你想要一列更新,我們稱之爲TIMESTAMP_COL。該觸發器會是這樣的:

CREATE TRIGGER Background_Process_Report_trit 
AFTER INSERT 
ON Background_Process_Report 
FOR EACH ROW 
WHEN (NEW.PROCESS_NAME IS NOT NULL) 
BEGIN 
    UPDATE EXECUTION_TIMESTAMP 
    SET TIMESTAMP_COL = NEW.TIMESTAMP 
    WHERE ???; -- Change ??? to the appropriate condition 
END; 
/

我假設的「IF INSERT(PROCESS_NAME)」你的意思是「如果一個非空值插入PROCESS_NAME」,並創建了一個WHEN子句來匹配。

+0

謝謝...它工作正常 – murali 2010-06-07 06:01:16