Oracle sql trigger if updating

Oracle automatically executes a trigger when a specified event takes place, which may be in the form of a system event or a DML statement being issued against the table.

:old.sal); dbms_output.put(' New salary: '

NEXTVAL INTO : NEW.my_col3 FROM DUAL; END IF; IF : NEW.my_col4 IS NULL THEN (...) END IF; END; / CREATE OR REPLACE TRIGGER my_trg2 BEFORE UPDATE ON my_table FOR EACH ROW BEGIN IF : NEW.my_col IS NULL THEN raise_application_error(...); END IF; IF : NEW.my_col2 IS NULL THEN : NEW.my_col2 := (...); END IF; END; / I can't see any major advantage to one or the other.

Oracle Developer/Administrator Certified Associate program is a unique program combining the required courses to become an Oracle Certified Associate both as a Developer and as an Administrator.

This program helps to certify professionals who want to demonstrate they posses the knowledge and hands-on skills required to support Oracle's products.

CREATE or REPLACE TRIGGER test001 AFTER INSERT OR UPDATE OR DELETE ON tabletest001 REFERENCING OLD AS old_buffer NEW AS new_buffer FOR EACH ROW WHEN (new_buffer.field1 = 'HBP00' OR old_buffer.field1 = 'HBP00') DECLARE Operation NUMBER; Customer Code CHAR(10 BYTE); BEGIN IF DELETING THEN Operation := 3; Customer Code := :old_buffer.field1; END IF; IF INSERTING THEN Operation := 1; Customer Code := :new_buffer.field1; END IF; IF UPDATING THEN Operation := 2; Customer Code := :new_buffer.field1; END IF; // DO SOMETHING ...

--------------------------------------------- | PK | Name | Address | Postal Code | --------------------------------------------- | 1 | AA | Street1 | 11111 | | 2 | BB | Street2 | 22222 | | 3 | CC | Street3 | 33333 | --------------------------------------------- --------------------------------------------- | PK | Name | Address | Postal Code | --------------------------------------------- | 1 | AA | Street1 | 11111 | | 2 | BB | Street2 | 44444 | | 3 | CC | Dtreet7 | 33333 | --------------------------------------------- What client wants is the update records and only the updated columns (yes, I know it doesn't make any sense but they use some old system from 1970s and they want to do some logging etc.).

The actions you're performing on the data is technically different between the insert/update portions, but what about the business logic difference?