dbTalk Databases Forums  

SQL 2000 DTS Loop error

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


Discuss SQL 2000 DTS Loop error in the microsoft.public.sqlserver.dts forum.



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

Default SQL 2000 DTS Loop error - 01-25-2005 , 07:35 PM






I have a SQL DTS that imports a file and does a loop to get the next file.
It works fine with the first file but get an error on the second file. The
error is "cannot open data file, cannot find file"on the transfom data pump
task. I know it can find the find since the activex script msgbox displays
the correct file path & name. I believe the error is with the disable step
and/or execution status because I can get the same error on an activex script
task by changing the disable step status or execuion status. I hope you can
help, any ideas. Thanks,

Here is the ActiveX GET FILE Task:
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Option Explicit

Function Main()

' Declare FSO Related Variables
Dim sRecvFolder
Dim sRecvFileName
Dim sRecvFileBatch
Dim sHistFolder
Dim sRecvFileFound
Dim sSendACKNFile
Dim sSendFolder
Dim sModDate
Dim fso
Dim fsoFolder
Dim fsoFile
Dim fsoHistFolder
Dim fsoFolderSend

'Declare Variables
Dim oPKG
Dim oConnection
dim stpEnterLoop
dim stpFinished

' Import Folder
sSendFolder = DTSGlobalVariables("gvSendFolder")

sRecvFolder = DTSGlobalVariables("gvRecvFolder")
sHistFolder = DTSGlobalVariables("gvHistFolder")
sModDate = FormatDateTime(Now,2)

DTSGlobalVariables("gvModDate").value = sModDate

Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sRecvFolder)
Set fsoHistFolder = fso.GetFolder(sHistFolder)
Set fsoFolderSend = fso.GetFolder(sSendFolder)
Set oPKG = DTSGlobalVariables.Parent

sRecvFileFound = "NO"
'************************************************* ***********************
MSGBOX "START"
Msgbox oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Execut ionStatus

For Each fsoFile in fsoFolder.Files
sRecvFileFound = "NO"
' Get first filename
sRecvFileName = fsoFile.Name
DTSGlobalVariables("gvRecvFileName").value = sRecvFileName
MsgBox sRecvFolder&sRecvFileName

If Ucase (Left(sRecvFileName,4)) = "INVD" and fso.getfile(sRecvFolder &
sRecvFileName).Size>0 Then
fso.CopyFile sRecvFolder & sRecvFileName, sHistFolder & sRecvFileName
sRecvFileBatch = Mid(sRecvFileName, 6, (InStr(6,sRecvFileName, ".")-6))
DTSGlobalVariables("gvRecvFileBatch").value = sRecvFileBatch
sRecvFileFound = "YES"

' Get Package Object
Set oPKG = DTSGlobalVariables.Parent

' Get Source Connection Object
Set oConnection = oPKG.Connections("Connect1")

' Set new Filename
oConnection.DataSource =sRecvFolder&sRecvFileName

oPkg.Steps("DTSStep_DTSDataPumpTask_1").DisableSte p = False
oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus =
DTSStepExecStat_Waiting
' oPkg.Steps("DTSStep_DTSDataPumpTask_1").Execute

oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Disabl eStep = False
oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus =
DTSStepExecStat_Waiting

' oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Disabl eStep = True
oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Execut ionStatus =
DTSStepExecStat_Inactive

MsgBox "file found"
Msgbox oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Execut ionStatus

Exit For
End If
'************************************************* ***********************


If Ucase (Left(sRecvFileName,4)) = "INVD" and fso.getfile(sRecvFolder &
sRecvFileName).Size=0 Then
'Msgbox "INVD delt"
sRecvFileFound = "ZERO"
fso.CopyFile sRecvFolder & sRecvFileName, sHistFolder & sRecvFileName
sRecvFileBatch = Mid(sRecvFileName, 6, (InStr(6,sRecvFileName, ".")-6))
DTSGlobalVariables("gvRecvFileBatch").value = sRecvFileBatch
fso.DeleteFile sRecvFolder & sRecvFileName
sSendACKNFile = "ACKN_"&sRecvFileBatch&".txt"
fso.CreateTextFile sSendFolder&sSendACKNFile
fso.CopyFile sSendFolder&sSendACKNFile, sHistFolder & sSendACKNFile

Set oPKG = DTSGlobalVariables.Parent

oPkg.Steps("DTSStep_DTSDataPumpTask_1").DisableSte p = False
' oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus =
DTSStepExecStat_Inactive

oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Disabl eStep = False
oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus =
DTSStepExecStat_Waiting
oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut e

oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Disabl eStep = False
oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Execut ionStatus =
DTSStepExecStat_Inactive

Exit For
End If
'************************************************* ***********************
'Msgbox "next"
Next

'************************************************* ***********************

If (sRecvFileFound) = "NO" Then
' Get Package Object
'MsgBox "file NOT found"
Set oPKG = DTSGlobalVariables.Parent

oPkg.Steps("DTSStep_DTSDataPumpTask_1").DisableSte p = True
oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus =
DTSStepExecStat_Inactive

oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Disabl eStep = True
oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus =
DTSStepExecStat_Inactive

oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Disabl eStep = False
oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Execut ionStatus =
DTSStepExecStat_Waiting

End If
'************************************************* ***********************

Main = DTSTaskExecResult_Success
End Function

Here is the ActiveX LOOP Task:
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

Dim oPkg
Dim oStep

MsgBox "Loop "

' Get reference to the Package
Set oPkg = DTSGlobalVariables.Parent

' Get reference to the step at the start of the loop
'' Set oStep = oPkg.Steps("DTSStep_DTSActiveScriptTask_1")

' Set the status back to waiting
'' oStep.ExecutionStatus = DTSStepExecStat_Waiting

oPkg.Steps("DTSStep_DTSDataPumpTask_1").DisableSte p = False
oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus =
DTSStepExecStat_Waiting

oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Disabl eStep = False
oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus =
DTSStepExecStat_Waiting

oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Disabl eStep = False
oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus =
DTSStepExecStat_Waiting

Msgbox oPkg.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_3").Execut ionStatus
Msgbox oPkg.Steps("DTSStep_DTSActiveScriptTask_5").Execut ionStatus


oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut e

' Clean Up


' Set oStep = Nothing
' Set oPkg = Nothing
Main = DTSTaskExecResult_Success
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.