dbTalk Databases Forums  

Global variable doesn't retain value

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


Discuss Global variable doesn't retain value in the microsoft.public.sqlserver.dts forum.



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

Default Global variable doesn't retain value - 07-13-2003 , 03:45 PM






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,
Ed

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

Default Re: Global variable doesn't retain value - 07-14-2003 , 01:35 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



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.