You are here: Re: Trigger Error « MsSQL Server « IT news, forums, messages
Re: Trigger Error

Posted by Hugo Kornelis on 05/27/05 22:02

On 26 May 2005 17:08:00 -0700, coosa wrote:

>My question now, when i insert multiple records, isn't the trigger
>still fired after each single insert?

Hi coosa,

Only if you use seperate insert statements. If you use something like

INSERT INTO MyTable (Col1, Col2, ...)
SELECT Col1, Col2, ...
FROM OtherTable
WHERE ....

then the trigger will fire once, regardless of whether the number of
rows inserted is zero, one, two or 3,000,000,000.

I stick to my advice: remove the derived column, and use a user-defined
function to calculate the depth when you retrieve data. Or, when you
don't want to do that, check out the suggestion posted by Erland: it
will work fone, even for multi-row inserts, as long as you never insert
both a parent and a child in the same statement (and it's not very hard
to adapt the code to cater for that possibility as well).

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация