indolent
indolent

Reputation: 3391

How to set new date entries to current date?

I am trying to create a trigger. It is supposed to update any new date entry to sysdate. So far, I have the following code. However, I get "invalid table name" and "SQL statement ignored" errors.

CREATE OR REPLACE TRIGGER new_orders
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
    IF INSERTING THEN
       UPDATE
           SET order_date := SYSDATE;
    END IF;
END;
/

Upvotes: 2

Views: 8080

Answers (1)

zerkms
zerkms

Reputation: 255045

CREATE OR REPLACE TRIGGER new_orders
BEFORE INSERT ON orders
FOR EACH ROW
BEGIN
    :NEW.order_date := SYSDATE;
END;
/

Upvotes: 9

Related Questions