473,382 Members | 1,348 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,382 software developers and data experts.

What type of TRIGGER to use?

MAS
Is there a type of TRIGGER that I can use to do do post-INSERT
processing? I've got one table that I never want to block the INSERT,
but instead need to do post INSERT processing on. The only way I know
to do this is via a JOB, which isn't ideal in this scenerio.

mas
Jul 20 '05 #1
5 7003
Mas,

Check the Books Online and look for CREATE TRIGGER. You can specify whether
a trigger fires before or after an action. (Or even insted of it, so you can
override the action)
Example:

create trigger TriggerName
on YourTable
after insert
as
<TriggerBody>

Good luck,
Shervin

"MAS" <di***********@yahoo.com> wrote in message
news:47**************************@posting.google.c om...
Is there a type of TRIGGER that I can use to do do post-INSERT
processing? I've got one table that I never want to block the INSERT,
but instead need to do post INSERT processing on. The only way I know
to do this is via a JOB, which isn't ideal in this scenerio.

mas

Jul 20 '05 #2
Shervin Shapourian (Sh**********@hotmail.com) writes:
Check the Books Online and look for CREATE TRIGGER. You can specify
whether a trigger fires before or after an action. (Or even insted of
it, so you can override the action)


To be more precise, you have the choices of AFTER and INSTEAD OF. There
is no BEFORE trigger. If you go for INSTEAD OF, you need handle the
insert/update/delete operation yourself.
--
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
Erland,

I thought FOR is used for BEFORE triggers, but I was wrong. Thanks for the
correction. This is what I like about newsgroups, you always learn new
things, especially when you get envolved in problem solving.

Thanks again,
Shervin
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1...
Shervin Shapourian (Sh**********@hotmail.com) writes:
Check the Books Online and look for CREATE TRIGGER. You can specify
whether a trigger fires before or after an action. (Or even insted of
it, so you can override the action)


To be more precise, you have the choices of AFTER and INSTEAD OF. There
is no BEFORE trigger. If you go for INSTEAD OF, you need handle the
insert/update/delete operation yourself.
--
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 #4
MAS
Thanks Shervin. The AFTER INSERT trigger worked.
Jul 20 '05 #5
Shervin Shapourian wrote:
Erland,

I thought FOR is used for BEFORE triggers, but I was wrong. Thanks for the
correction. This is what I like about newsgroups, you always learn new
things, especially when you get envolved in problem solving.

Thanks again,
Shervin
"Erland Sommarskog" <so****@algonet.se> wrote in message
news:Xn*********************@127.0.0.1...

Shervin Shapourian (Sh**********@hotmail.com) writes:

Check the Books Online and look for CREATE TRIGGER. You can specify
whether a trigger fires before or after an action. (Or even insted of
it, so you can override the action)

To be more precise, you have the choices of AFTER and INSTEAD OF. There
is no BEFORE trigger. If you go for INSTEAD OF, you need handle the
insert/update/delete operation yourself.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Correct. If you want BEFORE triggers you need to use Oracle, DB2, or
Informix.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
da******@x.washington.edu
(replace 'x' with a 'u' to reply)

Jul 20 '05 #6

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

Similar topics

2
by: Cherry | last post by:
I have a trigger that won't compile: CREATE OR REPLACE TRIGGER TRG_CORRESPONDENCE_UPT AFTER UPDATE on TBLCORRESPONDENCE for each row BEGIN IF :OLD.Keywords <> :NEW.Keywords THEN
4
by: Pecos Bill | last post by:
Salve, non riesco a disabilitare un trigger su sqlserver nč da query analyzer, nč da enterprise manager. In pratica tal cosa riuscivo a farla in Oracle con TOAD, mentre qui non riesco. Mi...
4
by: signaturefactory | last post by:
I get the following error for this procedure: Server: Msg 156, Level 15, State 1, Procedure Trig_Ins_TrackingNumbers, Line 6 Incorrect syntax near the keyword 'IF'. CREATE TRIGGER...
3
by: kjaggi | last post by:
I am trying to either write a trigger or a check constraint to prevent duplicates in my table. There are two columns I need to look at for the duplicates and only one combo value for both columns...
6
by: Mary | last post by:
We are developing a DB2 V7 z/OS application which uses a "trigger" table containing numerous triggers - each of which is activated by an UPDATE to a different column of this "trigger" table. When...
0
by: sheenaa | last post by:
Hi Everyone, I m using ASP.NET 2005 with C# and SQL SERVER 2005. I m using stored procedure and sql datasource control to retrieve the data. I want to use the trigger...
7
by: Shane | last post by:
I have been instructed to write a trigger that effectively acts as a foreign key. The point (I think) is to get me used to writing triggers that dont use the primary key(s) I have created the...
2
by: kage | last post by:
I am trying to use this with mushclient 3.84 it supports these type of scripts. If anyone could help me figure out which type of script it is or convert it to any of those that my client uses....
2
by: Parnamwulan | last post by:
Hello guys, Pls dont laugh - it is not funny (actually it is, but it is causing me problems) I have problem with SQLDA data type specification. I need to create some counted columns, so I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.