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 *** |