Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Triggers within the SQL forums, part of the Databases category; How to wite Tiggers in sql? Give me the example.........
|
|||||||
|
|||
|
Re: Triggers
Lets say you want to create trigger on table1 having columns id and name.
The syntax would be create trigger insert on my_table as begin insert into my_table values (0,"new NAME inserted") end for any insert into your my_table object as below: insert into my_table values (1,"name1") O/P will be: id name -- ------ 1 name1 0 new NAME inserted The above is an example for insert trigger. Similarly you can create update and delete triggers. Last edited by keerthv; 04-23-2008 at 06:58 AM. |
|
|||
|
Re: Triggers
By SQL if you mean SQL Server then please find a related discussion here.
|
| The Following User Says Thank You to debasisdas For This Useful Post: | ||
|
|||
|
Re: Triggers
Hi usha, here is an example.. Example to create table level or statement triggers create or replace trigger secure_emp before insert on emp begin if to_char(sysdate,’dy’) in(‘sat’,’sun’) or to_char(sysdate,’hh24:mi’) not between ’08:00’ and ’18:00’ then raise_application_error(-20001,’you may insert into emp table only during business hours..’); end if; end; / here is the output.. testing secure_emp insert into emp (empno, ename) values (101,’ravi’); error at line 1 ora-20001 you may insert into emp table only during business hours ora-06512 at plsql secure_emp, line 4 ora-04088 error during execution of trigger “plsql secure_emp” regards, e.sagar.
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Views, Triggers, Normalization | bharathi_ark | SQL Server | 9 | 11-10-2007 06:21 AM |
| which Triggers have been Expired in Oracle 10g | Medix | Oracle Apps | 0 | 08-03-2007 04:06 PM |
| Sequence of commit triggers | Geek_Guest | Oracle | 0 | 07-10-2007 01:49 PM |
| About Report Triggers | JobHelper | Oracle | 3 | 01-09-2007 08:01 AM |
| Triggers Types | scott | SQL | 1 | 07-30-2006 07:18 PM |