all groups > sql server dts > july 2003 >
You're in the

sql server dts

group:

Global variable doesn't retain value


Global variable doesn't retain value Eddie
7/13/2003 1:45:22 PM
sql server dts:
Hi,
I have global variable which I change within one of the
DTS package tasks (Active X). I want to store date and
time of package execution in this global variable, so I
can use it for next execution.
The problem is that global variable doesn't remember new
date/time, assigned within Active X task, but after
execution keeps always the same value, defined during
designing phase of the package (DTS designer).
Within the package, everything works fine, which means
that all other tasks use correct value of the Global
Variable, assigned in Active X task (see below)...
Here is the active x code which I use, for global
variable change:

Function Main()
DTSGlobalVariables("BeginDateTime").Value = CStr
(Now)
if Err <>0 then
Main = DTSTaskExecResult_Failure
else
Main = DTSTaskExecResult_Success
end if
End Function

Thanks in advance,
Re: Global variable doesn't retain value Allan Mitchell
7/14/2003 7:35:16 AM
Hello, Eddie!

That is correct it does not remember the last value you placed in there.
That is due to the fact that when you change it you are not saving the
package back. This isn't a bad design feature either. If DTS was built so
that when you changed the GV it saved the package back then as we know
everytime you do that it creates a new value in the sysdtspackages table in
turn giving you a new Version ID. If you use this to qualify your package
execution then you will not be picking up the new version.

Save the value to a DB Table or some other method of persistent storage if
you want to carry it around.

--

Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org

: Function Main()
: DTSGlobalVariables("BeginDateTime").Value = CStr
: (Now)
: if Err <>0 then
: Main = DTSTaskExecResult_Failure
: else
: Main = DTSTaskExecResult_Success
: end if
: End Function

--- Microsoft CDO for Windows 2000

AddThis Social Bookmark Button