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 Trigger Problem within the Oracle forums, part of the Databases category; Hi all, iam created two tables names like t1 and t2.the follwoing structures are like this t1->create table t1(id int ,name varchar2(50),status int) t2->create table t2(id int ,name varchar2(50),status int) ...
|
|||||||
| Oracle Oracle 9i & Oracle 10g Knowledge Base Learn and Share Oracle Technology related articles, white papers, tutorials / study materials, example codes, FAQ's, Tips and Tricks. |
![]() |
| LinkBack | Thread Tools | Display Modes |
|
|||
|
Trigger Problem
Hi all, iam created two tables names like t1 and t2.the follwoing structures are like this t1->create table t1(id int ,name varchar2(50),status int) t2->create table t2(id int ,name varchar2(50),status int) when status changed in t1 (if status=1 then) table it will delete that row and insert into t2 table so, i created one trigger like this but it is not excuted it's giving complie errors,please help me out create or replace trigger updatetrigger after update of status on t1 for each row declare cursor c_t1 is select * from t1 where status!=0; begin delete from t1 where status!=0; for eachtrigger1 in c_t1 loop insert into t2 values(eachtrigger1.id,eachtrigger1.name,eachtrigger1.status) end loop; end updatetrigger;
|
| Sponsored Links |
|
|||
|
Re: Trigger Problem
@sanjeev,
Dear, U have missed out the semi-colon at the end of insert statement, thats why some error may occur. Just execute the following stuff Code:
create or replace trigger update_trigger after update of status on t1 for each row declare cursor c_t1 is select * from t1 where status!=0; begin delete from t1 where status!=0; for eachtrigger1 in c_t1 loop insert into t2 values(eachtrigger1.id,eachtrigger1.name,eachtrigger1.status); end loop; end update_trigger; |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Logical Mechanism of Trigger / How DB thinks about Trigger | tvgiriprasad | Oracle | 4 | 06-04-2009 03:30 AM |
| trigger | Thirumurugan.K | Oracle | 4 | 11-27-2008 07:30 AM |
| what is a trigger? | srinu.tenali | SQL Server | 11 | 11-10-2008 12:57 AM |
| Trigger | goodstudent | SQL | 2 | 03-14-2008 06:03 AM |
| what is trigger | amaravadi11 | SQL | 8 | 01-23-2008 03:10 PM |