Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
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 December 11th, 2006, 12:02 PM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question for Trigger

I'm new at triggers and I have to create one.
The scenario is:

There is one table T1 and it has its primary key as ID which is autogenerated by Identity. I want a trigger Insert, it should fire, once I do the insert on T1, it should also insert some columns to T2. I also need tht identity column value. How should I do this?

Thanks for all your help.

 
Old December 13th, 2006, 08:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there...
this is for SQL server?

HTH

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

If U r using SQL Server then....
You can Get all the information about the record just inserted from INSERTED Table, This is a Temporary System Table used to hold the row for Last insertion and can be queried as u do with user created table, It has the structure of the table u r inserting row in.

If U r using ORACLE Db then....
There two bind variables 1- :new and 2- :old
both holds new & old values respectively.

U can use these variables as...
:new.<columnName>
:old.<columnName>


Akhil





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trigger question for columns with text in MS sql s robtay SQL Server 2000 1 November 12th, 2006 03:21 PM
Trigger aware SQL Server 2000 1 April 15th, 2005 01:28 PM
do I need a trigger? Warbird SQL Server 2000 1 April 5th, 2005 08:07 AM
Using instead of trigger dmr999 SQL Server 2000 1 November 29th, 2003 02:35 PM
trigger khautinh SQL Server 2000 5 October 16th, 2003 11:33 AM





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