Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
How can I use a database event
How can I use a database event
Rate Topic
Display Mode
Topic Options
Author
Message
MikeLPlates
MikeLPlates
Posted Sunday, December 06, 2009 11:45 AM
Grasshopper
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 2:42 AM
Points: 13,
Visits: 90
Hi
Apologies if I'm posting in the wrong place - but this seemed the closest.
What I've done.....
When a loading process is finished, it updates the final stage status of a record to Completed.
I've put in a place a trigger which then inserts a row into another database on this status change
This then fires off 3 triggers to perform certain subsequent activity - in effect 3 procedures.
The issue I have it that this is all part of the original transaction. (In this case, if the two databases were out of sync, I'm not bothered, I have a recovery mechanism.) My concern, is that whilst the 3 triggered procedures are running on Database B, I could be holding locks on the original database.
Ideally, if using Ingres. I would write the three procedures to register for a Database event 'File Completed'. The trigger on the Database Insert table would raise the event 'File Completed' with the associated ID, and the original transaction would commit.
I think a similar thing could be done in Oracle wih Advanced Queueing.
I thought I might be able to use this solution with SQL Server - but it seems to be only DDL. Does anyone have any elegant solutions?
Regards
Mike
Post #829546
Jeff Moden
Jeff Moden
Posted Sunday, December 06, 2009 8:06 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 1:51 PM
Points: 32,906,
Visits: 26,789
If you consider the way you'd do it in Ingres "elegant", then why not just do it that way? Write the 3 stored procedures.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #829604
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Sunday, December 06, 2009 9:39 PM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 6:14 PM
Points: 31,421,
Visits: 13,734
I don't think there's a more elegant way. You could use the DTC (distributed transaction coordinator), but it would hold locks until things were committed, and if your link was down, you couldn't commit anything.
The slightly more elegant way in SQL is to use Service Broker to Q the event and have it picked up by the other database and take action there. that way if there were some comm issue, you could still commit the event in the first database/table and when things were working, it would occur in the second one. That leaves you some loose coupling, but the chance that things are out of sync for some time.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #829632
Jack Corbett
Jack Corbett
Posted Monday, December 07, 2009 7:02 AM
SSChampion
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:22 PM
Points: 10,571,
Visits: 11,871
I agree with Steve that Service Broker is probably a way to do what you are looking at doing.
Jack Corbett
Applications Developer
Don't let the good be the enemy of the best. --
Paul Fleming
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #829826
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.