dbTalk Databases Forums  

Loop rowset values for connection

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


Discuss Loop rowset values for connection in the microsoft.public.sqlserver.dts forum.



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

Default Loop rowset values for connection - 02-06-2004 , 03:36 AM






How can I loop the rowset values one by one for data connection? I've only checked if there're values in the recordset and assign the connection values as follows. I would like to ask where I can assign the execution status (stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting) to loop back for next recordset and exit the loop if the recordset is finished.

If not oRS.BOF The
Set oConn1 = DTSGlobalVariables.Parent.Connections("Sybase ASE OLE DB Provider"
oConn1.DataSource = Trim(oRS.Fields(0).Value) ' source server
oConn1.Catalog = Trim(oRS.Fields(1).Value) ' source D

Set oConn = DTSGlobalVariables.Parent.Connections("SQL Server"
oConn.DataSource = Trim(oRS.Fields(3).Value) ' dest. Serve
oConn.Catalog = Trim(oRS.Fields(4).Value) ' dest. D

Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTas
oDataPump.SourceObjectName = Trim(oRS.Fields(2).Value) ' source table
oDataPump.DestinationObjectName = Trim(oRS.Fields(5).Value) ' dest. tabl

Set oDataPump = Nothin
Set oConn = Nothin
Set oConn1 = Nothin

oRS.MoveNex
End I

I've followed the example at http://www.sqldts.com/default.aspx?246

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Loop rowset values for connection - 02-06-2004 , 07:43 AM






Try this, as it si closer to what you want.

How to loop through a global variable Rowset
(http://www.sqldts.com/Default.aspx?298)

Replace step 2 with your DataPump. Note that step 2 has workflow script
which you need to change to include all of your connection and task setting
stuff, and put it back onto your task. This could be done in a Script Task
if you like.
See step 3 workflow code for where to set DTSStepExecStat_Waiting.

--
Darren Green
http://www.sqldts.com

"sbox" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
How can I loop the rowset values one by one for data connection? I've only
checked if there're values in the recordset and assign the connection values
as follows. I would like to ask where I can assign the execution status
(stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting) to loop back for
next recordset and exit the loop if the recordset is finished.
Quote:
If not oRS.BOF Then
Set oConn1 = DTSGlobalVariables.Parent.Connections("Sybase ASE OLE DB
Provider")
oConn1.DataSource = Trim(oRS.Fields(0).Value) ' source server
oConn1.Catalog = Trim(oRS.Fields(1).Value) ' source DB

Set oConn = DTSGlobalVariables.Parent.Connections("SQL Server")
oConn.DataSource = Trim(oRS.Fields(3).Value) ' dest. Server
oConn.Catalog = Trim(oRS.Fields(4).Value) ' dest. DB

Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask
oDataPump.SourceObjectName = Trim(oRS.Fields(2).Value) ' source table
oDataPump.DestinationObjectName = Trim(oRS.Fields(5).Value) ' dest. table

Set oDataPump = Nothing
Set oConn = Nothing
Set oConn1 = Nothing

oRS.MoveNext
End If


I've followed the example at http://www.sqldts.com/default.aspx?246



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

Default Re: Loop rowset values for connection - 02-08-2004 , 09:26 AM



Do you mean that I could combine the step 2 workflow scripts into the task script
How about the step 3 workflow code? Could it be written into the last task script to loop back step 2

I notice that it always check "If oRS.EOF" in both workflow script and task script. How can it determine the current recordset? Do I need to check it if I write all codes in task script ?

Reply With Quote
  #4  
Old   
sbox
 
Posts: n/a

Default Re: Loop rowset values for connection - 02-08-2004 , 10:06 PM



I don't know how to combine workflow script and task script together

I just use the example in http://sqldts.com/?246 and replace the connection stuff into step 2's task script. I could display the correct recordset values one by one. However, the data pump connection can only be completed at the last recordset. ie. I've 2 records in recordset. Only the last record's data are transformed to the destination location. I've also set the workflow properties's option = close connection on completion. What's the problem ? Do I need to add some steps or scripts to link up the connection

- replace e.g. 298 step 2's task scrip
Function Main(
Dim oR
Dim oConn, oConn1
Dim oPkg, oDataPum

Set oRS = DTSGlobalVariables("RSTables").Valu
Set oPkg = DTSGlobalVariables.Paren

MsgBox "Dest. DB:" & vbCrLf & oRS.Fields(4).Value & vbCrLf ' show correct value

Set oConn1 = DTSGlobalVariables.Parent.Connections("SQL Server 2"
oConn1.DataSource = Trim(oRS.Fields(0).Value) ' source server
oConn1.Catalog = Trim(oRS.Fields(1).Value) ' source D

Set oConn = DTSGlobalVariables.Parent.Connections("Sybase 1"
oConn.DataSource = Trim(oRS.Fields(3).Value) ' dest. Serve
oConn.Catalog = Trim(oRS.Fields(4).Value) ' dest. D

Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTas
oDataPump.SourceObjectName = Trim(oRS.Fields(2).Value) ' source table
oDataPump.DestinationObjectName = Trim(oRS.Fields(5).Value) ' dest. tabl

Set oDataPump = Nothin
Set oConn = Nothin
Set oConn1 = Nothin

oRS.MoveNex

Set oRS = Nothin
Main = DTSTaskExecResult_Succes
End Function

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.