Trigger if updating inserting

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.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 need to write an Insert, Update Trigger on table A which will delete all rows from table B whose one column (say Desc) has values like the value inserted/updated in the table A's column (say Col1).How would I go around writing it so that I can handle both Update and Insert cases. Table Name AFTER INSERT, UPDATE, DELETE AS BEGIN SET NOCOUNT ON; -- -- Check if this is an INSERT, UPDATE or DELETE Action.Whenever INSERT is happened in the CUSTOMER table, I need to call the "Stored Procedure1"and UPDATE is happend in the CUSTOMER table, I need to call the "Stored Procedure2" in the Trigger.How to determine if insert or update in the trigger from SQL Server 2008. Code: CREATE TRIGGER Notifications ON CUSTOMER FOR INSERT, UPDATE AS BEGIN DECLARE @record Id varchar(20); set @record Id= new.Triggers in sql server fire once per operation and your triggers need to handle multiple rows operations. You will slow your system down to unbelievably low levels.

IMO, your best bet is to contain a functional unit of work inside of a trigger, so that there is no discrepancy in what that trigger does.Then have another process pick up the rows in the extra table and process them accordingly.CREATE TRIGGER Insert Notifications ON CUSTOMER FOR INSERT AS BEGIN DECLARE @record Id varchar(20); set @record Id= new.Id; //if trigger is insert at the time I call to SP1 EXEC Stored Procedure1 @record Id //if trigger is Upadeted at the time I call to SP2 EXEC Stored Procedure2 @record Id END A couple of really major things here.First of all you should NEVER use a scalar variable in a trigger that is populated from the inserted or deleted values.

Leave a Reply

  1. corey bohan dating audrina patridge 18-Nov-2019 14:44

    This Site Contains Adult Material We have no association and hold no responsibility for the links on this site!

  2. Telugu aunty live phone chat 20-Apr-2019 16:16

    Satisfying, long he understands and he treats you like a girlfriend, you’ll soon find what you comfortable with relationship to just come out and play with partner and establish the plan.