DTS Help - Execute task/step in a loop with changed SQL ... -
03-09-2005
, 05:05 AM
Hi,
Here is my problem:
I have an Excel file containing a list of funds. I can open it easily enough
and read the funds.
Now I need to execute a Transformation task for each fund by looping through
the funds in the Excel file, and execute a SQL Query using the currect fund
against a table, then output that to a CSV file.
So inside the llop I need to change the SQL of the Data Transformation task,
execute it, then continue to the next one...
I have a Data Pump Transformation task, and I can retrieve the SQL
Statement, and reset it...
so how can I execute the Data Pump once for each fund?
here is my ActiveX Script so far...
======================
Function Main()
dim oFso, sDate, sMonth, sDay, oFile, sYear, sTime
dim sSrcLocation, sWorkingDir, sWorkingFile, sArchiveDir, sArchiveName
dim objExcel, xlWorkbook, xlSheet
dim sSrcPath, sSrcFile, sFund, oDataPumpTask, oDataPump
Set oPkg = DTSGlobalVariables.Parent
Set oDataPump = oPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask
' Assign SQL Statement to Source of DataPump
' oDataPump.SourceSQLStatement = sSQLStatement
msgbox oDataPump.SourceSQLStatement
' Get Global Vars
sSrcPath = DTSGlobalVariables("SrcPath").value
set objExcel=CreateObject("Excel.Application")
set xlWorkbook = objExcel.workbooks.open(sSrcPath)
set xlSheet = xlworkbook.worksheets("control")
xlsheet.activate
msgbox(xlsheet.range("A2").text)
xlsheet.range("A2").activate
Do While Not objExcel.activecell.Text = ""
sFund = trim(objExcel.activecell.Text)
objExcel.activecell.offset(1, 0).Select
Loop
xlworkbook.close true
objExcel.quit
End Function
======================
thanks for any tips or help, or code that will help me...
Philip |