![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
First of all, credit goes to http://www.sqldts.com/default.aspx?246 for helping me with this idea. Basically I have several files I wish to |
|
Below is the start of my loop...and right off the bat I have issues. First - When I execute, a error pops up: "Task 'DTSStep_DTSExecuteSQLTask_1' was not found." Well it is there. I changed the workflow option on that task and even copied and paste the name. I think it bombs out here: set stpEnterLoopPG1 = pkg.Steps("DTSStep_DTSExecuteSQLTask_1") I'm sure I will have more flaws in the code below, but I need to get past line 20 for a change ;-). Thanks for your time... Richard '================================================= ===================== Option Explicit Function Main() dim pkg dim bulkTextFilePG1 dim stpEnterLoopPG1 dim stpFinishedPG1 Dim bulkSQLTablePG1 Dim SQLTaskPG1 set pkg = DTSGlobalVariables.Parent ' set stpEnterLoopPG1 = pkg.Steps("DTSTask_DTSBulkInsertTask_1").CustomTas k 'This is the Bulk Insert |
|
'Instead of starting the loop on the Bulk Insert Task, start on the SQL Task - to truncate the table prior to Insert. set stpEnterLoopPG1 = pkg.Steps("DTSStep_DTSExecuteSQLTask_1") 'This is the SQL Task... set stpFinishedPG1 = pkg.Steps("DTSStep_DTSActiveScriptTask_2") set bulkTextFilePG1 = pkg.Tasks("DTSTask_DTSBulkInsertTask_1") Set bulkSQLTablePG1 = pkg.Tasks("DTSTask_DTSBulkInsertTask_1") Set SQLTaskPG1 = pkg.Tasks("DTSStep_DTSExecuteSQLTask_1") ' We want to continue with the loop only of there are more ' than 1 file to process in the process group. If the function ShouldILoop ' returns true then we disable the step that takes us out of the package ' and continue processing if ShouldILoop = True then stpEnterLoopPG1.DisableStep = False stpFinishedPG1.DisableStep = True 'Supply the Source file for the Bulk Insert Task. bulkTextFilePG1.DataFile = DTSGlobalVariables("gvWNBDir").Value & DTSGlobalVariables("gvImportFilePG1").Value 'Supply the Destination Table for the Bulk Insert Task. bulkSQLTablePG1.DestinationTableName = DTSGlobalVariables("gvSQLTablePG1").Value SQLTaskPG1.SQLStatement = "Truncate Table " & DTSGlobalVariables("gvSQLTablePG1").Value stpEnterLoopPG1.ExecutionStatus = DTSStepExecStat_Waiting else stpEnterLoopPG1.DisableStep = True stpFinishedPG1.DisableStep = False stpFinishedPG1.ExecutionStatus = DTSStepExecStat_Waiting End if Main = DTSTaskExecResult_Success End Function Function ShouldILoop dim pkg Dim sProcess 'Here read from the database to find the next file to Bulk Insert into the database. sDSN = DTSGlobalVariables("gvDSN").value '"Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=WNB;Data Source=DEVSQL01;" 'ConnectToDatabase Set oCN = CreateObject("ADODB.Connection") oCN.Open sDSN 'Get the next process... sQry = "select top 1 process from processes where processgroup = '1' and status = 'D' order by process" Set oRS = CreateObject("ADODB.Recordset") oRS.CursorType = 3 'adUseStatic - must be to get a record count oRS.open sQry, oCN 'Check to see if there are records in the record set (oRS) If oRS.RecordCount > 0 Then Do Until oRS.EOF sProcess = oRS.Fields(0).Value oRS.MoveNext Loop ' MsgBox sProcess set pkg = DTSGlobalVariables.Parent 'Set the Source Text file for import on the Bulk Insert Task... DTSGlobalVariables("gvImportFilePG1").Value = sProcess & ".txt" 'Set the Destination table for the Bulk Insert Task...and Set which table to pass to the SQL Task for truncate... DTSGlobalVariables("gvSQLTablePG1").Value = sProcess ShouldILoop = CBool(True) Else ' MsgBox "Nothing" ShouldILoop = CBool(False) End If oRS.Close End Function |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |