Sunday, February 1, 2015

Triggers / Oracle / Oracle SQL Developer


In this tutorial we are going to create a simple trigger to update the count when a new row is added.

(Please note that this tutorial is just to demonstrate a simple  trigger,)

Create a table called EMP1. Refer this for more details about creating tables and inserting data


And create EMPCOUNT1 table too . 



Create the trigger as depicted in the image.










select * from EMP1

insert into emp1 values ('7','sad','3000')

select * from empcount1

Above commands can be used to demonstrate the Trigger. Once a new row is inserted the count is incremented by 1. (Refer the trigger)

create or replace TRIGGER "COUNTTEST" BEFORE INSERT ON EMP1
FOR EACH ROW
BEGIN
 update empcount1
 set EMP_COUNT = EMP_COUNT +1;
END;




No comments:

Post a Comment

Using Zotero for academic writing