dbTalk Databases Forums  

SQLDTS multiple paths in workflow

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


Discuss SQLDTS multiple paths in workflow in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kevin R.
 
Posts: n/a

Default SQLDTS multiple paths in workflow - 02-01-2006 , 04:26 PM






Hi All,

I am using the following code from SQLDTS.com to implement multiple
paths in workflow:

' 218 (SetupPath)
Option Explicit

' /* Change these constants to suit your package */

' Name of the global variabled used to decide the path
' This example requires a boolean
Const DTSPath_GlobalVariable_Name = "FirstTime"

' Name of the first Step in the "True" Path
Const DTSPath_True_First_Step = "DTSStep_DTSActiveScriptTask_2"
' Name of the last Step in the "True" Path
Const DTSPath_True_Last_Step = "DDTSStep_DTSActiveScriptTask_2"

' Name of the first Step in the "False" Path
Const DTSPath_False_First_Step = "DTSStep_DTSActiveScriptTask_3"
' Name of the last Step in the "False" Path
Const DTSPath_False_Last_Step = "DTSStep_DTSActiveScriptTask_3"

' Name of OR Step
Const DTSPath_OR_Step = "DTSStep_DTSActiveScriptTask_4"


Function Main()

Dim oPkg, oConstraints, oConstraint

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

' Diable the workflow path we are not using
oPkg.Steps(DTSPath_True_First_Step).DisableStep = _
Not DTSGlobalVariables(DTSPath_GlobalVariable_Name).Va lue
oPkg.Steps(DTSPath_False_First_Step).DisableStep = _
DTSGlobalVariables(DTSPath_GlobalVariable_Name).Va lue

' Get reference to the PrecedenceConstraints collection,
' for which we need to simulate the OR
Set oConstraints = oPkg.Steps(DTSPath_OR_Step).PrecedenceConstraints


If DTSGlobalVariables("FirstTime").Value Then
' Set our True path OR
Set oConstraint = GetConstraint(oConstraints, DTSPath_True_Last_Step)
oConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecResult
oConstraint.Value = DTSStepExecResult_Success

Set oConstraint = GetConstraint(oConstraints, DTSPath_False_Last_Step)
oConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecStatus
oConstraint.Value = DTSStepExecStat_Inactive Or
DTSStepExecStat_Waiting
oPkg.Steps(DTSPath_False_Last_Step).ExecutionStatu s = _
DTSStepExecStat_Inactive Or DTSStepExecStat_Waiting
Else
' Set our False path OR
Set oConstraint = GetConstraint(oConstraints, DTSPath_False_Last_Step)
oConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecResult
oConstraint.Value = DTSStepExecResult_Success

Set oConstraint = GetConstraint(oConstraints, DTSPath_True_Last_Step)
oConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecStatus
oConstraint.Value = DTSStepExecStat_Inactive Or
DTSStepExecStat_Waiting
oPkg.Steps(DTSPath_True_Last_Step).ExecutionStatus = _
DTSStepExecStat_Inactive Or DTSStepExecStat_Waiting
End If

Set oPkg = Nothing
Set oConstraints = Nothing
Set oConstraint = Nothing

Main = DTSTaskExecResult_Success
End Function

Function GetConstraint(oConstraints, sStepName)
' Get Constraint by Source Step Name
Dim oConstraint
For Each oConstraint In oConstraints
If oConstraint.StepName = sStepName Then
Set GetConstraint = oConstraint
Exit For
End If
Next
End Function


But, I get the folowing VB runtime error when Script Task is executed
which I can not shake off. Does anyone know what is causing it:

Object Required: 'GetConstraint(...)'

thx,
kr

*** Sent via Developersdex http://www.developersdex.com ***

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.