dbTalk Databases Forums  

How to I branch in a DTS package based on the values of a global variable

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


Discuss How to I branch in a DTS package based on the values of a global variable in the microsoft.public.sqlserver.dts forum.



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

Default How to I branch in a DTS package based on the values of a global variable - 03-15-2006 , 06:07 PM







We have a scheduled package that will check the value in a table row and based
on that value will either
- run a series of steps including execute sql and activex
- exit successfully

detail

we

set the DB
set Global Variable

run a SQL query to determine if the package is running (its endtime is < than
startime meaning its running since one of the 1st steps is to update a row
with it startime) this ExecuteSQL task has no input variable but generates an
output variable (gvRunning) as an integer

run a SQL query to determin if we should run (we ask fo a count of rows, if >
1 we run else not) this ExecuteSQL task has no input variable but generates
an output variable (gvCount) as an integer

at this point we want to do the following:

if he output variable gvcount is = 0 or gvRunning = 1 we want to exit the
whole package

if the output variable is > 0 and the gvRunning = 0 we want to perform a
series of step (activex, executeSQL etc)

the solution we have come up with is

- after getting gvCount and gvRunning run an Activex script that has 2
workflows. on success do the good stuff, and
Function Main()

if DTSGlobalVariables("gvCount").Value = "0" or
DTSGlobalVariables("gvRunning").Value = "1" THEN
Main = DTSTaskExecResult_Failure
ELSE
Main = DTSTaskExecResult_Success
END IF

End Function

works great execpt of course that the package ends in a failure, logs get
written message sent to DBA etc.


we also tried this but everything gets done everytime

Function Main()

if DTSGlobalVariables("gvCountRequest").Value = "0" or
DTSGlobalVariables("gvIsRunning").Value = "1" THEN
Set oPkg = DTSGlobalVariables.Parent
Set oExecSQL =
oPkg.Tasks("DTSTask_DTSExecutePackageTask_3").Cust omTask
oExecSQL.PackageName = "NBT_DummyPackage_DEV"
Main = DTSTaskExecResult_Success
ELSE
Main = DTSTaskExecResult_Success
END IF

End Function
anyone have any ideas on how to do this? we

Reply With Quote
  #2  
Old   
jlcaesar@gmail.com
 
Posts: n/a

Default Re: How to I branch in a DTS package based on the values of a global variable - 03-15-2006 , 08:49 PM






You could set a global variable to true or false , then use a dynamic
task to set the next step's DisableStep property to true or false from
that global variable.


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

Default Re: How to I branch in a DTS package based on the values of a global variable - 03-15-2006 , 09:37 PM



In article <1142477343.535919.26400 (AT) j52g2000cwj (DOT) googlegroups.com>, "jlcaesar (AT) gmail (DOT) com" <jlcaesar (AT) gmail (DOT) com> wrote:
Quote:
You could set a global variable to true or false , then use a dynamic
task to set the next step's DisableStep property to true or false from
that global variable.

so you mean after we get the two values based on that value we disable all the
subsequent steps using a dynamic task causing the package to exist
successfully at that point?

so we should be able to disable everything from one task?


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

Default Re: How to I branch in a DTS package based on the values of a global variable - 03-16-2006 , 02:33 AM



colin

for all your special trik using dts vist www.sqldts.com. on this site
most isues (like loops in dts, branching conditiol switch etc.) are
discused with sample code to download. This site realy helped me with
my current assigenment

Michiel


Reply With Quote
  #5  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: How to I branch in a DTS package based on the values of a global variable - 03-16-2006 , 03:26 AM



Hello Colin,

What you are after then is conditional workflow. We have a number of examples
on the site and you can start here.

http://www.sqldts.com/default.aspx?246

Have a look at section 4 of the article where we turn and off flows in the
workflow.


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
We have a scheduled package that will check the value in a table row
and based
on that value will either
- run a series of steps including execute sql and activex
- exit successfully
detail

we

set the DB
set Global Variable
run a SQL query to determine if the package is running (its endtime is
than startime meaning its running since one of the 1st steps is to
update a row with it startime) this ExecuteSQL task has no input
variable but generates an output variable (gvRunning) as an integer

run a SQL query to determin if we should run (we ask fo a count of
rows, if > 1 we run else not) this ExecuteSQL task has no input
variable but generates an output variable (gvCount) as an integer

at this point we want to do the following:

if he output variable gvcount is = 0 or gvRunning = 1 we want to exit
the whole package

if the output variable is > 0 and the gvRunning = 0 we want to perform
a series of step (activex, executeSQL etc)

the solution we have come up with is

- after getting gvCount and gvRunning run an Activex script that has
2 workflows. on success do the good stuff, and Function Main()

if DTSGlobalVariables("gvCount").Value = "0" or
DTSGlobalVariables("gvRunning").Value = "1" THEN
Main = DTSTaskExecResult_Failure
ELSE
Main = DTSTaskExecResult_Success
END IF
End Function

works great execpt of course that the package ends in a failure, logs
get written message sent to DBA etc.

we also tried this but everything gets done everytime

Function Main()

if DTSGlobalVariables("gvCountRequest").Value = "0" or
DTSGlobalVariables("gvIsRunning").Value = "1" THEN
Set oPkg = DTSGlobalVariables.Parent
Set oExecSQL =
oPkg.Tasks("DTSTask_DTSExecutePackageTask_3").Cust omTask
oExecSQL.PackageName = "NBT_DummyPackage_DEV"
Main = DTSTaskExecResult_Success
ELSE
Main = DTSTaskExecResult_Success
END IF
End Function
anyone have any ideas on how to do this? we



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.