dbTalk Databases Forums  

Using trigger with a datapump

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Using trigger with a datapump in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
RayAll
 
Posts: n/a

Default Using trigger with a datapump - 03-22-2005 , 05:31 PM






I am transferring records from one table to another table using a Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and when
the control gose to the next record field4 has a value of either 1 or 0.Now
I'd like to insert records which their Field4 is equal to 1 to a different
table ,but I'd like to do it through a tirgger so while I'm transferring the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Using trigger with a datapump - 03-23-2005 , 02:42 PM






You can use a trigger yes but then your trigger code would have to
handle batch size. This may also be slow.

Why not make two passes over the source inserting into the correct table
each time. Your SELECT would then need to become qualified (WHERE)

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote


Quote:
I am transferring records from one table to another table using a Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and when
the control gose to the next record field4 has a value of either 1 or 0.Now
I'd like to insert records which their Field4 is equal to 1 to a different
table ,but I'd like to do it through a tirgger so while I'm transferring the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks


Reply With Quote
  #3  
Old   
RayAll
 
Posts: n/a

Default Re: Using trigger with a datapump - 03-23-2005 , 03:05 PM



Thanks for yuor reply.

I didn't get this.
Quote:
Why not make two passes over the source inserting into the correct table
each time. Your SELECT would then need to become qualified (WHERE)
What I am currently doing is using a sp to do so.but the problem is that I
run the sp after I insert (and validate) records to a buffer table and then
I go through the records and decide what to do with them.I was looking for a
better and faster solution to this that I rememberd the triggers.so you
think trigger might slow down this process right?

Thanks again

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
You can use a trigger yes but then your trigger code would have to handle
batch size. This may also be slow.

Why not make two passes over the source inserting into the correct table
each time. Your SELECT would then need to become qualified (WHERE)

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote


I am transferring records from one table to another table using a
Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and
when
the control gose to the next record field4 has a value of either 1 or
0.Now
I'd like to insert records which their Field4 is equal to 1 to a
different
table ,but I'd like to do it through a tirgger so while I'm transferring
the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks




Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Using trigger with a datapump - 03-23-2005 , 03:20 PM



Oh yes.

The way to tell is test.

The thing about the DTS way without triggers is that anything else
inserting into that table will not fire a trigger because there isn't
one.

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote


Quote:
Thanks for yuor reply.

I didn't get this.
Why not make two passes over the source inserting into the correct table
each time. Your SELECT would then need to become qualified (WHERE)

What I am currently doing is using a sp to do so.but the problem is that I
run the sp after I insert (and validate) records to a buffer table and then
I go through the records and decide what to do with them.I was looking for a
better and faster solution to this that I rememberd the triggers.so you
think trigger might slow down this process right?

Thanks again

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:umvrtg%23LFHA.1180 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
You can use a trigger yes but then your trigger code would have to handle
batch size. This may also be slow.

Why not make two passes over the source inserting into the correct table
each time. Your SELECT would then need to become qualified (WHERE)

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote


I am transferring records from one table to another table using a
Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and
when
the control gose to the next record field4 has a value of either 1 or
0.Now
I'd like to insert records which their Field4 is equal to 1 to a
different
table ,but I'd like to do it through a tirgger so while I'm transferring
the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks



Reply With Quote
  #5  
Old   
RayAll
 
Posts: n/a

Default Re: Using trigger with a datapump - 03-23-2005 , 04:57 PM



But,I 's like to use the trigger in the buffer table and any insert should
fire the trigger.If I don't use the trigger than I'll have to come back and
itterate through all records once more (the way I am doing this now) to
enforce the rules (I am doing this using a stored procedure now) Is it
better than having the trigger on each insert?

Thanks for following this thread up.
Ray
"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Oh yes.

The way to tell is test.

The thing about the DTS way without triggers is that anything else
inserting into that table will not fire a trigger because there isn't one.

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote


Thanks for yuor reply.

I didn't get this.
Why not make two passes over the source inserting into the correct
table
each time. Your SELECT would then need to become qualified (WHERE)

What I am currently doing is using a sp to do so.but the problem is that
I
run the sp after I insert (and validate) records to a buffer table and
then
I go through the records and decide what to do with them.I was looking
for a
better and faster solution to this that I rememberd the triggers.so you
think trigger might slow down this process right?

Thanks again

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:umvrtg%23LFHA.1180 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
You can use a trigger yes but then your trigger code would have to
handle
batch size. This may also be slow.

Why not make two passes over the source inserting into the correct
table
each time. Your SELECT would then need to become qualified (WHERE)

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote in message
news:RayAll (AT) microsft (DOT) com:

I am transferring records from one table to another table using a
Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and
when
the control gose to the next record field4 has a value of either 1 or
0.Now
I'd like to insert records which their Field4 is equal to 1 to a
different
table ,but I'd like to do it through a tirgger so while I'm
transferring
the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks





Reply With Quote
  #6  
Old   
Simon Worth
 
Posts: n/a

Default Re: Using trigger with a datapump - 03-24-2005 , 08:08 AM



why not push your records to your buffer table, then do 2 insert
statements, both with a qualified where statement. The first insert
would push your records to the first table, and the second insert would
push only those records WHERE Field4 = 1.
Are you actually looping through each record in the buffer table
(iterate through all records) or just running an insert statement with a
where clause in it?

Simon Worth

RayAll wrote:
Quote:
But,I 's like to use the trigger in the buffer table and any insert should
fire the trigger.If I don't use the trigger than I'll have to come back and
itterate through all records once more (the way I am doing this now) to
enforce the rules (I am doing this using a stored procedure now) Is it
better than having the trigger on each insert?

Thanks for following this thread up.
Ray
"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:eqKvv1%23LFHA.732 (AT) TK2MSFTNGP12 (DOT) phx.gbl...

Oh yes.

The way to tell is test.

The thing about the DTS way without triggers is that anything else
inserting into that table will not fire a trigger because there isn't one.

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote



Thanks for yuor reply.

I didn't get this.

Why not make two passes over the source inserting into the correct
table
each time. Your SELECT would then need to become qualified (WHERE)

What I am currently doing is using a sp to do so.but the problem is that
I
run the sp after I insert (and validate) records to a buffer table and
then
I go through the records and decide what to do with them.I was looking
for a
better and faster solution to this that I rememberd the triggers.so you
think trigger might slow down this process right?

Thanks again

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:umvrtg%23LFHA.1180 (AT) TK2MSFTNGP14 (DOT) phx.gbl...

You can use a trigger yes but then your trigger code would have to
handle
batch size. This may also be slow.

Why not make two passes over the source inserting into the correct
table
each time. Your SELECT would then need to become qualified (WHERE)

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote in message
news:RayAll (AT) microsft (DOT) com:


I am transferring records from one table to another table using a
Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and
when
the control gose to the next record field4 has a value of either 1 or
0.Now
I'd like to insert records which their Field4 is equal to 1 to a
different
table ,but I'd like to do it through a tirgger so while I'm
transferring
the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks




Reply With Quote
  #7  
Old   
RayAll
 
Posts: n/a

Default Re: Using trigger with a datapump - 03-24-2005 , 11:10 AM



No,I don't iterate through the records:-)

I simply use an insert statement( which is quite fast) ,but I was thinking
that if I enforce the business rules through trigger.that makes more
sence,but if you think that would slow down the whole process.I have
absolutely no problem with using the sp after I have inserted everything to
the buffer table.
Another question here:

in buffer table I have for example 4 fields Field1 Filed2 Field3 Field4

I insert each record into different tables Field1 and Filed2 go to one table
,where Field3 gose to another Table and Field4 as well.Is there a way to
combine all these actions and have only one insert statement which dose care
of all the insertes into different tables? or I have to write different
insert statements?


Question#2) When I use insert statement with a qualified where clause ,dose
it itereate through all records to find out the records which match with the
criteria in where clause? how dose it find the records??


Thanks
"Simon Worth" <REMOVEFIRST_simon.worth (AT) gmail (DOT) com> wrote

Quote:
why not push your records to your buffer table, then do 2 insert
statements, both with a qualified where statement. The first insert would
push your records to the first table, and the second insert would push
only those records WHERE Field4 = 1.
Are you actually looping through each record in the buffer table (iterate
through all records) or just running an insert statement with a where
clause in it?

Simon Worth

RayAll wrote:
But,I 's like to use the trigger in the buffer table and any insert
should fire the trigger.If I don't use the trigger than I'll have to come
back and itterate through all records once more (the way I am doing this
now) to enforce the rules (I am doing this using a stored procedure now)
Is it better than having the trigger on each insert?

Thanks for following this thread up.
Ray
"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:eqKvv1%23LFHA.732 (AT) TK2MSFTNGP12 (DOT) phx.gbl...

Oh yes.

The way to tell is test.

The thing about the DTS way without triggers is that anything else
inserting into that table will not fire a trigger because there isn't
one.

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote



Thanks for yuor reply.

I didn't get this.

Why not make two passes over the source inserting into the correct
table
each time. Your SELECT would then need to become qualified (WHERE)

What I am currently doing is using a sp to do so.but the problem is that
I
run the sp after I insert (and validate) records to a buffer table and
then
I go through the records and decide what to do with them.I was looking
for a
better and faster solution to this that I rememberd the triggers.so you
think trigger might slow down this process right?

Thanks again

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:umvrtg%23LFHA.1180 (AT) TK2MSFTNGP14 (DOT) phx.gbl...

You can use a trigger yes but then your trigger code would have to
handle
batch size. This may also be slow.

Why not make two passes over the source inserting into the correct
table
each time. Your SELECT would then need to become qualified (WHERE)

Allan

"RayAll" <RayAll (AT) microsft (DOT) com> wrote in message
news:RayAll (AT) microsft (DOT) com:


I am transferring records from one table to another table using a
Datapump
task.each record looks like the following:

Field1 Field2 Field3 Field4

While transferring the field1 to 3 ,I update Field4 (it's my flag) and
when
the control gose to the next record field4 has a value of either 1 or
0.Now
I'd like to insert records which their Field4 is equal to 1 to a
different
table ,but I'd like to do it through a tirgger so while I'm
transferring
the
records ,that insert takes place as weel.I was thinking about using
trigger.Is it possible to use trigger for that scenario?

Thanks




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.