dbTalk Databases Forums  

Execute Sql Server Task and Global Variable

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


Discuss Execute Sql Server Task and Global Variable in the microsoft.public.sqlserver.dts forum.



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

Default Execute Sql Server Task and Global Variable - 02-01-2006 , 07:30 PM






Hi there,

I have a dts package that first pulls records into a temp table. I
also have a Global Variable of type boolean called ContinueProcessing.
Once the task runs that populates the temp table I have an Execute Sql
Server Task that checks to see if there are records and if there are it
should set the Global Variable to true. I then have a workflow activex
that if the Global Variable is true, it continues, otherwise there is
no reason to run the rest of the tasks so I set Main =
DTSStepScriptResult_DontExecuteTask. My problem is I keep getting an
error with my code in the Execute Sql server task.

If EXISTS (SELECT * from tempFile)
BEGIN
SET DTSGlobalVariables("ContinueProcessing").Value = True
END

At this step I get the following error:
Deferred Prepare Could Not Be Completed. Statement(s) Could Not Be
Prepared. Line 3 Incorrect Syntax Near "(".

Is this a syntax error I just can't see or am I taking the wrong
approach? Any help would be appreciated.


Reply With Quote
  #2  
Old   
bharat jariwala
 
Posts: n/a

Default RE: Execute Sql Server Task and Global Variable - 02-02-2006 , 04:29 AM






Your approach is wrong.

Do this way:

1.Create stored procedure with output parameter say "@ContinueProcessing"
2.Write EXISTS (SELECT * from tempFile) inside stored procedure.
3 return value of @ContinueProcessing from procedure as per your logic.
4.Call stored procedure from Execute SQL task like
Exec StoredProcedureName ?

Where "?" is your GlobalVariable - ContinueProcessing.

--
Regards
Bharat Jariwala



"rowan" wrote:

Quote:
Hi there,

I have a dts package that first pulls records into a temp table. I
also have a Global Variable of type boolean called ContinueProcessing.
Once the task runs that populates the temp table I have an Execute Sql
Server Task that checks to see if there are records and if there are it
should set the Global Variable to true. I then have a workflow activex
that if the Global Variable is true, it continues, otherwise there is
no reason to run the rest of the tasks so I set Main =
DTSStepScriptResult_DontExecuteTask. My problem is I keep getting an
error with my code in the Execute Sql server task.

If EXISTS (SELECT * from tempFile)
BEGIN
SET DTSGlobalVariables("ContinueProcessing").Value = True
END

At this step I get the following error:
Deferred Prepare Could Not Be Completed. Statement(s) Could Not Be
Prepared. Line 3 Incorrect Syntax Near "(".

Is this a syntax error I just can't see or am I taking the wrong
approach? Any help would be appreciated.



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

Default Re: Execute Sql Server Task and Global Variable - 02-02-2006 , 11:23 AM



Thanks for your response. What I ended up doing which worked very well
was changing the global variable type to integer and changing the code
in the Execute SQL task to

SELECT count(*) as cnt from tempFile

Then I clicked on Parameters in the Execute task, selected the Output
parameters tab, selected the option Row Value, and then set the
Parameter cnt to my Global Variable ContinueProcessing. Then in the
workflow I changed my if statement from "if
GlobalVariables("ContinueProcessing") = true" to "if
GlobalVariables("ContinueProcessing") > 0"
DTSStepScriptRewsultExecuteTask else
DTSStepScriptResult_DontExecuteTask. It worked like a charm.


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.