Reputation: 21
Essentially I wish to create a trigger that keeps track and edits the date_created
column of a specific row after every insert or update.
These are the columns in my table:
| customer_id | store_id | Quantity | date_created |
the customer_id and store_id together are the primary key of the table
What I have so far:
CREATE OR REPLACE TRIGGER date_trig
BEFORE INSERT ON customer_table
FOR EACH ROW
DECLARE
BEGIN
-- This is where I assume the date will be set or edited
END;
I am brand new to PL/SQL so I am struggling with the actual body of this trigger.
Also, do I have the structure of a trigger correctly formed?
Upvotes: 0
Views: 7148
Reputation: 358
Hi Please find sample code.
create or replace trigger emp_mod_date
before update or insert on emp
for each row
begin
:new.mdate := sysdate;
end;
Upvotes: 1
Reputation: 729
DEFAULT SYSDATE
on the colum date_created
like already suggested:NEW.date_created := SYSDATE;
Upvotes: 0