dbTalk Databases Forums  

Global Variable value cannot update in ActiveX Script Task

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


Discuss Global Variable value cannot update in ActiveX Script Task in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
too.changmian@gmail.com
 
Posts: n/a

Default Global Variable value cannot update in ActiveX Script Task - 12-05-2006 , 08:51 PM






Hi all,

I want to call stored procedure from my DTS, after execute the SQL , i
want to pass the global variable to ActiveX Script. However, the global
variable in ActiveX Script only hold the default value

Here is my stored procedure:

CREATE PROCEDURE sp_test123
@TotalCountSum int OUTPUT

AS

SET NOCOUNT ON
-- Create two integer values
DECLARE @tableOneCount int, @tableTwoCount int

-- Get the number of rows from the first table

SELECT @tableOneCount = (SELECT COUNT(*) FROM FundCode)

SELECT @tableTwoCount = (SELECT COUNT(*) FROM FundCode_1)

SELECT @TotalCountSum=@tableOneCount - @tableTwoCount


GO


Then i call the stored procedure from "Execute SQL Task" in DTS

DECLARE @TotalCountSum INT
EXEC sp_test123 @TotalCountSum OUTPUT
SET NOCOUNT ON
SELECT @TotalCountSum AS 'CountDiff'


I had set a global variable "TotalCountSum" , so i map the CountDiff to
TotalCountSum.
After that, i write an ActiveX Script:


Function Main()

if DTSGlobalVariables("TotalCountSum").Value <> 0 then
Main = DTSTaskExecResult_Success
else
Main = DTSTaskExecResult_Failure
end if

End Function


If the TotalCountSum not equal to 0, then i will send an email
notification out. However, the TotalCountSum keep return only the
default value that i set to it. Can anyone tell me how to solve it?

Thanks


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

Default Re: Global Variable value cannot update in ActiveX Script Task - 12-06-2006 , 04:15 PM






Hello too.changmian (AT) gmail (DOT) com,

You could rewrite the proc to be

CREATE PROCEDURE sp_test123
@TotalCountSum int OUTPUT

AS

SET NOCOUNT ON

SET @TotalCountSum=(SELECT COUNT(*) FROM FundCode) + (SELECT COUNT(*) FROM
FundCode_1)


GO


Have you seen this as well?

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



Regards

Allan Mitchell
Konesans Ltd
T +44 7966 476 572
F +44 2071 008 479
http://www.konesans.com

Quote:
Hi all,

I want to call stored procedure from my DTS, after execute the SQL , i
want to pass the global variable to ActiveX Script. However, the
global variable in ActiveX Script only hold the default value

Here is my stored procedure:

CREATE PROCEDURE sp_test123
@TotalCountSum int OUTPUT
AS

SET NOCOUNT ON
-- Create two integer values
DECLARE @tableOneCount int, @tableTwoCount int
-- Get the number of rows from the first table

SELECT @tableOneCount = (SELECT COUNT(*) FROM FundCode)

SELECT @tableTwoCount = (SELECT COUNT(*) FROM FundCode_1)

SELECT @TotalCountSum=@tableOneCount - @tableTwoCount

GO

Then i call the stored procedure from "Execute SQL Task" in DTS

DECLARE @TotalCountSum INT
EXEC sp_test123 @TotalCountSum OUTPUT
SET NOCOUNT ON
SELECT @TotalCountSum AS 'CountDiff'
I had set a global variable "TotalCountSum" , so i map the CountDiff
to
TotalCountSum.
After that, i write an ActiveX Script:
Function Main()

if DTSGlobalVariables("TotalCountSum").Value <> 0 then
Main = DTSTaskExecResult_Success
else
Main = DTSTaskExecResult_Failure
end if
End Function

If the TotalCountSum not equal to 0, then i will send an email
notification out. However, the TotalCountSum keep return only the
default value that i set to it. Can anyone tell me how to solve it?

Thanks




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.