Geeks Talk

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.

Trigger Problem

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

Go Back   Geeks Talk > Databases > Oracle
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

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.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2009
Junior Member
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sanjeev.thummala is on a distinguished road
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;
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-01-2009
Contributing Member
 
Join Date: Dec 2008
Location: bangalore
Posts: 76
Thanks: 0
Thanked 18 Times in 18 Posts
ecearund is on a distinguished road
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;
Reply With Quote
Reply

  Geeks Talk > Databases > Oracle

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 02:46 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved