Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Call trigger after commit on tables

Author  Topic 

bo0tl3ss
Starting Member

20 Posts

Posted - 2011-08-10 : 04:26:41
Hi good day,

i have two tables to insert the Message and the ListOfNumbers table.

how can i execute trigger in Message table after all row is insert on the ListOfNumbers?

anyone got idea?

Thanks in advanced!



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-10 : 07:30:10
Sorry not clear. why do you need to call one tables trigger based on another tables insert action? If you want to do some processing based on insert action on ListOfNumbers you need to create a insert trigger on it and not on Message

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-08-10 : 17:32:44
Every SQL forum or newsgroup expects that you will post DDL, sample data and clear specifications which might might include output. This is explained in the FAQ section. We can not read minds; what would we need to know to do your job for you?

Tables must have keys and should have DRI, constraints, and all the basic features of a schema. You should know use ISO-8601 Standards for temporal data, avoid needless dialect, basic data modeling and use ISO-11179 Standards for data element names. Please tell us if you can change the DDL.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

bo0tl3ss
Starting Member

20 Posts

Posted - 2011-08-10 : 21:38:35
okay sorry guys and thanks for the inputs, here is my problem. i have two tables the Message and the listofnumbers, i separated listofnumbers because one message will send to manny recipients which is the listofnumbers.

i need to insert first to message table so it will generate key that will be foreign key to the listofnumber table. then the insert on listofnumbers will be multiple. i dont want to execute the trigger everytime it insert on the listofnumbers. so i want after after committing on both tables then the trigger will execute.

the problem when i put the trigger on the Message table, the list is not yet insert so i got errors, when the trigger on listofnumbers, it call the trigger manny times.


ex:

on Message Table
this is sample message to be sent.

on ListOfNumbers Table
123467
123456
123133



this is an SMS system that use database to trigger the sending.


Thanks,



Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-08-11 : 12:08:46
I'm sorry, but I still don't understand what you want to do.

I have a couple of guesses.

1. You need to insert into two tables. If so, you can use a TRANSACTION to make sure they are both inserted/updated and if anyting goes wrong all will roll back.

2. You want to insert into a Queue and have a "trigger" send a message. If this is the case, you might be better off putting rows in a Queue and having a different process look for Messages that have not been sent and Send them and then update that row and mark it as Sent.

Now, if you want some actual help, you are going to have to describe, in words, what you are trying to do. After you ahve done that, then you can post your schema if you like. But, I can't understand the schema you've posted so far, so I'm skeptical that it's right. Here is a link that might help you organize your question better so we can help you:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -