if update sql

Solutions on MaxInterview for if update sql by the best coders in the world

showing results for - "if update sql"
Luca
17 Aug 2017
1-- SQL Server (update my_table after update on my_table)
2CREATE TRIGGER trTest ON my_table AFTER UPDATE AS
3IF UPDATE (col_name)	-- Optional, for particular column
4BEGIN
5    UPDATE my_table SET my_col_date = getdate() FROM my_table 
6END
7-- Oracle (insert into log table after update on my_table)
8CREATE OR REPLACE TRIGGER trTest AFTER UPDATE ON my_table
9FOR EACH ROW
10BEGIN
11    INSERT INTO my_log_table (LOG_DATE, ACTION) VALUES (SYSDATE, 'Changed');
12END;