Wrox Programmer Forums
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 7th, 2006, 03:29 AM
Authorized User
Join Date: Jun 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trigger Help

Hi Every1

I have problem in Trigger.I am new for that.Pls help me.

I have one table as Try.When I insert values in Try,at a time I want to fire Trigger for inserting and insert that value also in another table as Try1.

I got help but not understand why create temporary table in Trigger.Can we use direct table name in Trigger?

Pls help me if u have solution for triggers.Becoz I am completely new in this concept.


Old November 13th, 2006, 07:16 AM
Registered User
Join Date: Nov 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

hi monika,

the simplest of the code for your task could be

create or replace trigger
trigg_try_update before insert
on try
for each row
insert into try1(x,y) values (:new.x,:new.y);

here x and y are the columns(place whatever columns your table has) of the table try1 in which u want to insert values before inserting them to table try.

the default practise is to use pseudo names :new and :old to reference the new and old value of the table on which the trigger
is fired.{ remember that :new and :old cannot be used in case
of table level triggers }.

Old March 1st, 2007, 06:59 AM
Authorized User
Join Date: Mar 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

Hey Monica,

vijaykpit is right in case os ANSI SQL (used by ORACLE)

but if u r using SQL SERVER (T-Sql) then u won't find :new & :old bind varibles. Instead T-SQL provides two temporary system tables(INSERTED and DELETED) that hold the data used in the query. INSERTED table is used for INSER and UPDATE triggers, whereas DELETED is used in case of DELETE trigger. The structure of these tables are same as the table u r acting upon. U can query these table in the same manner as...

IN YOUR CASE, U should select the values from INSERTED table and INSERT these into TRY1 within The Trigger Body


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trigger fhillipo SQL Server 2000 1 March 20th, 2007 07:44 AM
Trigger arshad mahmood C++ Programming 4 June 24th, 2004 07:10 AM
Trigger ! minhtri Pro VB Databases 2 June 23rd, 2004 02:27 AM
Trigger arshad mahmood SQL Language 2 May 12th, 2004 05:16 AM
Using instead of trigger dmr999 SQL Server 2000 1 November 29th, 2003 02:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.