473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Trigger problem

Hi Folks,

My basic requirement is I want to write a trigger on a table based on
certain conditions post-update from another table in another database.

The actors in this scenario are:
Database D1, Table T1
Database D2, Table T2, T3

Action:
T1 updates T2

Requirement:
As soon as T2 is updated, I need to trigger an insert onto T3.
However, I do not want this action to be performed on every update on
T2 (other sources also update T2).
I want the trigger only for updates from T1.
I do not know how to go about it (conditional syntax for the update?)

I urgently require to solve this problem.
Thanks in advance for all those pitching in with help.

Best Regards,
Manoj S. Panicker
Jul 20 '05 #1
2 3088
Sorry I forgot to include the version of MS-SQL server. It is MS-SQL 7.0.
ma***@direct2s.com (Manoj S. P.) wrote in message news:<26*************************@posting.google.c om>...
Hi Folks,

My basic requirement is I want to write a trigger on a table based on
certain conditions post-update from another table in another database.

The actors in this scenario are:
Database D1, Table T1
Database D2, Table T2, T3

Action:
T1 updates T2

Requirement:
As soon as T2 is updated, I need to trigger an insert onto T3.
However, I do not want this action to be performed on every update on
T2 (other sources also update T2).
I want the trigger only for updates from T1.
I do not know how to go about it (conditional syntax for the update?)

I urgently require to solve this problem.
Thanks in advance for all those pitching in with help.

Best Regards,
Manoj S. Panicker

Jul 20 '05 #2
[posted and mailed, please reply in news]

Manoj S. P. (ma***@direct2s.com) writes:
My basic requirement is I want to write a trigger on a table based on
certain conditions post-update from another table in another database.

The actors in this scenario are:
Database D1, Table T1
Database D2, Table T2, T3

Action:
T1 updates T2

Requirement:
As soon as T2 is updated, I need to trigger an insert onto T3.
However, I do not want this action to be performed on every update on
T2 (other sources also update T2).
I want the trigger only for updates from T1.
I do not know how to go about it (conditional syntax for the update?)


If I understand this correctly, you have a trigger on T1 that updates T2,
and when T2 is updated through this trigger you want to cascade to T3,
but not when T2 is updated from other places.

This is a kind of odd thing to do, but it is actually possible. In T1
create a temp table, call it #do$updateT3, and in T2 you do:

IF object_id('tempdb..#do$updateT3') IS NOT NULL
UPDATE T3 ...

It doesn't matter what columns you have in the temp table, or if
there is any data. It's the table itself that serves as a global
flag variable.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Galina | last post by:
Hello I work with Oracle 9 database. I want to create a trigger using 2 tables: KEY_SKILLS_STUDENT and KEY_SKILLS. There are fields in KEY_SKILLS_STUDENT: KEY_SKILLS_ID, PORTFOLIO_RESULT and...
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
13
by: Tolik Gusin | last post by:
Hello All, DB2 UDB 8.1 FP3 for Linux The table has 4 triggers on the Insert operation. Three triggers small (200 bytes) and one trigger large (3 ËÂ). In the large trigger there is one long...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
5
by: William of Ockham | last post by:
Hi, I was asked to recreate a new clean database for our developers because the current one they use is not entirely up to date. So I created a new database and I run into the followin strange...
2
by: gustavo_randich | last post by:
Hi :-) I'm porting a project from Oracle to DB2 and now I'm trying to avoid error SQL0746N in a trigger which reads the same table in which the trigger is defined. Below is Oracle's...
12
by: Bob Stearns | last post by:
I am trying to create a duplicate prevention trigger: CREATE TRIGGER is3.ard_u_unique BEFORE UPDATE OF act_recov_date ON is3.flushes REFERENCING NEW AS N FOR EACH ROW MODE DB2SQL WHEN...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
2
by: dean.cochrane | last post by:
I have inherited a large application. I have a table which contains a hierarchy, like this CREATE TABLE sample_table( sample_id int NOT NULL parent_sample_id int NOT NULL ....lots of other...
1
by: veasnamuch | last post by:
I have a problem while I create a trigger to my table. My objective is getting any change made to my table and record it in to another table . My have thousands records before I add new trigger to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.