开发者

if insert error in oracle trigger creation?

开发者 https://www.devze.com 2023-01-02 12:03 出处:网络
CREATE TRIGGER Background_Process_Report_trit AFTER INSERT ON Background_Process_Report FOR EACH ROW IF INSERT(PROCESS_NAME)
  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 -- column in my Background_Process_Report table.but i want to update the each time the process_name is created(by java application), trigger update the time in the EXECUTION_TIMESTAMP table. but it is throwing the compliation error..

error:

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

how to reslove this 开发者_如何学Cerror


If EXECUTION_TIMESTAMP is a table as you say, then it must have a column you want to update, let's call it TIMESTAMP_COL. The the trigger would be something like:

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;
/

I have assumed that by "IF INSERT(PROCESS_NAME)" you mean "if a non-null value is inserted into PROCESS_NAME" and created a WHEN clause to match.

0

精彩评论

暂无评论...
验证码 换一张
取 消