Oracle if updating trigger

Once the trigger is created, entering the following SQL statement: A trigger is either a stored PL/SQL block or a PL/SQL, C, or Java procedure associated with a table, view, schema, or the database itself.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.The actions you're performing on the data is technically different between the insert/update portions, but what about the business logic difference?

oracle if updating trigger-10oracle if updating trigger-37

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 ...

I'm coding a Trigger to ensure only one type of money can be set as official.

Because the trigger uses the clause, it might be executed multiple times, such as when updating or deleting multiple rows.

You might omit this clause if you just want to record the fact that the operation occurred, but not examine the data for each row.

Triggers can be: Trigger names must be unique with respect to other triggers in the same schema.

Trigger names do not need to be unique with respect to other schema objects, such as tables, views, and procedures.

Since I would like to do the same things if the row is inserted, updated, or deleted, I would like to know what's happening in the trigger.

I think I can manage to find if the row is inserted or updated (I can check the old_buffer with the new_buffer). Detecting the DML Operation That Fired a Trigger If more than one type of DML operation can fire a trigger (for example, ON INSERT OR DELETE OR UPDATE OF Emp_tab), the trigger body can use the conditional predicates INSERTING, DELETING, and UPDATING to check which type of statement fire the trigger.

--------------------------------------------- | 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.).

Tags: , ,