dbTalk Databases Forums  

Is there a better way to skip multiple steps on no File?

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


Discuss Is there a better way to skip multiple steps on no File? in the microsoft.public.sqlserver.dts forum.



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

Default Is there a better way to skip multiple steps on no File? - 03-10-2005 , 06:49 PM






Is there anything wrong with this?
Or a better way to do this?

Ryan

Function Main()
Dim objFSO
Dim objFile
Dim objFolder
Dim strFileName
Dim strParentFolderName
Dim objPKG

Set objPKG = DTSGlobalVariables.Parent
strFileName = ""

strParentFolderName = DTSGlobalVariables("ParentFolderName").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strParentFolderName)

For Each objFile In objFolder.Files
if objFile.size <> 0 then
strFileName = objFile.Name
strAbsolutePathName = strParentFolderName & strFileName
DTSGlobalVariables("FileName").Value = strFileName
Exit For
end if

Next

IF strFileName = "" then
objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus =
DTSStepExecStat_Waiting
end if

Main = DTSTaskExecResult_Success
End Function


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

Default Re: Is there a better way to skip multiple steps on no File? - 03-11-2005 , 07:50 AM






With the code below, you are exiting your for loop when you get the first
filename that has data in it. Is this what you want to do, or do you want
to loop through all files in the folder and use the data pump task to insert
each file that has data.

Depends on what you want to do. If you want to loop through each file that
has data in the folder, and import them one at a time see this article
http://www.sqldts.com/default.aspx?246

--
Simon Worth


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

Quote:
Is there anything wrong with this?
Or a better way to do this?

Ryan

Function Main()
Dim objFSO
Dim objFile
Dim objFolder
Dim strFileName
Dim strParentFolderName
Dim objPKG

Set objPKG = DTSGlobalVariables.Parent
strFileName = ""

strParentFolderName = DTSGlobalVariables("ParentFolderName").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strParentFolderName)

For Each objFile In objFolder.Files
if objFile.size <> 0 then
strFileName = objFile.Name
strAbsolutePathName = strParentFolderName & strFileName
DTSGlobalVariables("FileName").Value = strFileName
Exit For
end if

Next

IF strFileName = "" then
objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus =
DTSStepExecStat_Waiting
end if

Main = DTSTaskExecResult_Success
End Function




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

Default Re: Is there a better way to skip multiple steps on no File? - 03-11-2005 , 11:01 AM



I understand looping (jumping backwards), but thanks anyways. I use a
similar script to jump back after I move the file out of the unprocessed
directory (thereby processing every file in the directory one at a time).
What I want to know is if this is the best way to jump forward? Basically,
will it skip the interrim steps without generating errors? I want to skip
the transformation step and a couple of transformation related steps, if
there are no files for the day, but still run the last few steps in one of
the logical branches (notifications, reports, etc).

"Simon Worth" wrote:

Quote:
With the code below, you are exiting your for loop when you get the first
filename that has data in it. Is this what you want to do, or do you want
to loop through all files in the folder and use the data pump task to insert
each file that has data.

Depends on what you want to do. If you want to loop through each file that
has data in the folder, and import them one at a time see this article
http://www.sqldts.com/default.aspx?246

--
Simon Worth


"Ryan" <Ryan (AT) discussions (DOT) microsoft.com> wrote in message
news:25E12962-454B-469C-92BC-99200EEF25E1 (AT) microsoft (DOT) com...
Is there anything wrong with this?
Or a better way to do this?

Ryan

Function Main()
Dim objFSO
Dim objFile
Dim objFolder
Dim strFileName
Dim strParentFolderName
Dim objPKG

Set objPKG = DTSGlobalVariables.Parent
strFileName = ""

strParentFolderName = DTSGlobalVariables("ParentFolderName").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strParentFolderName)

For Each objFile In objFolder.Files
if objFile.size <> 0 then
strFileName = objFile.Name
strAbsolutePathName = strParentFolderName & strFileName
DTSGlobalVariables("FileName").Value = strFileName
Exit For
end if

Next

IF strFileName = "" then
objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus =
DTSStepExecStat_Waiting
end if

Main = DTSTaskExecResult_Success
End Function





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

Default Re: Is there a better way to skip multiple steps on no File? - 03-11-2005 , 04:53 PM



I found the answer to my own question....

Replace the .executionStatus line with:


objPKG.Steps("DTSStep_DTSDataPumpTask_3").Execute
objPKG.Steps("DTSStep_DTSExecuteSQLTask_3").Execut ionStatus =
DTSStepExecStat_Inactive


"Ryan" wrote:

Quote:
I understand looping (jumping backwards), but thanks anyways. I use a
similar script to jump back after I move the file out of the unprocessed
directory (thereby processing every file in the directory one at a time).
What I want to know is if this is the best way to jump forward? Basically,
will it skip the interrim steps without generating errors? I want to skip
the transformation step and a couple of transformation related steps, if
there are no files for the day, but still run the last few steps in one of
the logical branches (notifications, reports, etc).

"Simon Worth" wrote:

With the code below, you are exiting your for loop when you get the first
filename that has data in it. Is this what you want to do, or do you want
to loop through all files in the folder and use the data pump task to insert
each file that has data.

Depends on what you want to do. If you want to loop through each file that
has data in the folder, and import them one at a time see this article
http://www.sqldts.com/default.aspx?246

--
Simon Worth


"Ryan" <Ryan (AT) discussions (DOT) microsoft.com> wrote in message
news:25E12962-454B-469C-92BC-99200EEF25E1 (AT) microsoft (DOT) com...
Is there anything wrong with this?
Or a better way to do this?

Ryan

Function Main()
Dim objFSO
Dim objFile
Dim objFolder
Dim strFileName
Dim strParentFolderName
Dim objPKG

Set objPKG = DTSGlobalVariables.Parent
strFileName = ""

strParentFolderName = DTSGlobalVariables("ParentFolderName").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strParentFolderName)

For Each objFile In objFolder.Files
if objFile.size <> 0 then
strFileName = objFile.Name
strAbsolutePathName = strParentFolderName & strFileName
DTSGlobalVariables("FileName").Value = strFileName
Exit For
end if

Next

IF strFileName = "" then
objPKG.Steps("DTSStep_DTSDataPumpTask_3").Executio nStatus =
DTSStepExecStat_Waiting
end if

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.