[英]How to create the correct trigger instead of insert or update? ORACLE. Trigger. pl/sql
[英]How to insert date in a table column with a trigger. (ORACLE)
本質上,我希望創建一個觸發器,以在每次插入或更新后跟蹤並編輯特定行的date_created
列。
這些是我表中的列:
| customer_id | store_id | Quantity | date_created |
customer_id和store_id一起是表的主鍵
到目前為止,我有:
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;
我是PL / SQL的新手,所以我為該觸發器的實際內容而苦苦掙扎。
另外,我是否正確形成了觸發器的結構?
嗨,請找到示例代碼。
create or replace trigger emp_mod_date
before update or insert on emp
for each row
begin
:new.mdate := sysdate;
end;
date_created
使用DEFAULT SYSDATE
:NEW.date_created := SYSDATE;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.