简体   繁体   中英

Trigger to update a record to null whenever there is an insert or update on a row in the table in Oracle DB

Need help in writting a Trigger to update a record to NULL whenever there is an insert or update on a row in the table in Oracle DB.

CODE

create or replace trigger updateRowToNull
AFTER
UPDATE OR INSERT
ON CUSTOMER for each row
BEGIN
update customer set customeraddr=NULL;
END;

A trigger cannot modify the table to which it is attached with a separate transaction. A "before" trigger can, however, manipulate column values within the transaction that causes it to be fired.

create or replace trigger update_row_to_null
before update or insert on customer
for each row
begin
   :new.customeraddr := null;
end;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM