dbTalk Databases Forums  

ActiveXScriptTask not running as described!

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


Discuss ActiveXScriptTask not running as described! in the microsoft.public.sqlserver.dts forum.



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

Default ActiveXScriptTask not running as described! - 09-10-2003 , 03:54 PM






Hello,

I modified this script to run creat four tasks using
customTasks.
When I executed this script, task, I was expecting
four "Hello World" messages to appear, why it did not?

Ahmed.

'************************************************* *********
************
' Visual Basic ActiveX Script
'************************************************* *********
**************
Option Explicit

Function Main()
Dim objPackage
Dim objStep
Dim objTask
Dim objScripTask
Dim Index
Dim taskname


Set objPackage = DTSGlobalVariables.Parent
For Each objTask in objPackage.Tasks

For Index = 1 to 4
taskname = "AXScr_Task" & Index

IF objTask.Name = taskname Then
objPackage.Tasks.Remove(taskname)
End If
Next
Next

For Each objStep in objPackage.Steps
IF objStep.Name = "AXScr_Step" Then
objPackage.Steps.Remove("AXScr_Step")
End If
Next
'create step and task, specify script, func name and
language
' Set objStep = objPackage.Steps.New

DTSGlobalVariables("GlobalOne").Value = 3

For Index = 1 to 4
Set objTask = objPackage.Tasks.New
("DTSActiveScriptTask")
Set objScripTask = objTask.CustomTask
objScripTask.Name = "AXScr_Task" & Index
MsgBox objScripTask.Name
objScripTask.ActiveXScript = _
"Function Main()" & vbCrLf & _
"MsgBox ""Hello World "" " & vbCrLf & _
"If DTSGlobalVariables( ""GlobalOne"" ) >
0 Then" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Success"
& vbCrLf & _
"Else" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Failure"
& vbCrLf & _
"End If" & vbCrLf & _
"End Function"

objScripTask.FunctionName = "Main"

objScripTask.ScriptLanguage = "VBScript"


'link step to task to package
'objStep.TaskName = objScripTask.Name
'objStep.Name = "AXScr_Step"
'objPackage.Steps.Add objStep

objPackage.Tasks.Add objTask
Next
objPackage.FailOnError = False


Set objPackage = Nothing
Set objStep = Nothing
Set objTask = Nothing
Set objScripTask = Nothing

Main = DTSTaskExecResult_Success

End Function


Reply With Quote
  #2  
Old   
Ken Cleveland
 
Posts: n/a

Default ActiveXScriptTask not running as described! - 09-10-2003 , 04:29 PM






Did you setup a workflow so that the new tasks would
execute after this initial task was finished?

Not sure you had to remove tasks and steps first. Just
set up your shell tasks with proper workflow and populate
them with requirted data.

Ken


Quote:
-----Original Message-----
Hello,

I modified this script to run creat four tasks using
customTasks.
When I executed this script, task, I was expecting
four "Hello World" messages to appear, why it did not?

Ahmed.

'************************************************* ********
*
************
' Visual Basic ActiveX Script
'************************************************* ********
*
**************
Option Explicit

Function Main()
Dim objPackage
Dim objStep
Dim objTask
Dim objScripTask
Dim Index
Dim taskname


Set objPackage = DTSGlobalVariables.Parent
For Each objTask in objPackage.Tasks

For Index = 1 to 4
taskname = "AXScr_Task" & Index

IF objTask.Name = taskname Then
objPackage.Tasks.Remove(taskname)
End If
Next
Next

For Each objStep in objPackage.Steps
IF objStep.Name = "AXScr_Step" Then
objPackage.Steps.Remove("AXScr_Step")
End If
Next
'create step and task, specify script, func name and
language
' Set objStep = objPackage.Steps.New

DTSGlobalVariables("GlobalOne").Value = 3

For Index = 1 to 4
Set objTask = objPackage.Tasks.New
("DTSActiveScriptTask")
Set objScripTask = objTask.CustomTask
objScripTask.Name = "AXScr_Task" & Index
MsgBox objScripTask.Name
objScripTask.ActiveXScript = _
"Function Main()" & vbCrLf & _
"MsgBox ""Hello World "" " & vbCrLf & _
"If DTSGlobalVariables( ""GlobalOne"" )
0 Then" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Success"
& vbCrLf & _
"Else" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Failure"
& vbCrLf & _
"End If" & vbCrLf & _
"End Function"

objScripTask.FunctionName = "Main"

objScripTask.ScriptLanguage = "VBScript"


'link step to task to package
'objStep.TaskName = objScripTask.Name
'objStep.Name = "AXScr_Step"
'objPackage.Steps.Add objStep

objPackage.Tasks.Add objTask
Next
objPackage.FailOnError = False


Set objPackage = Nothing
Set objStep = Nothing
Set objTask = Nothing
Set objScripTask = Nothing

Main = DTSTaskExecResult_Success

End Function

.


Reply With Quote
  #3  
Old   
Ahmed Zayan
 
Posts: n/a

Default ActiveXScriptTask not running as described! - 09-10-2003 , 04:59 PM



Hi Ken,

I added the steps and it works now, i also opened the
workflow of this Task and checked "Execute on Main Package
thread".

My question is those tasks should be executed on their own
thread, concurrent operation. I will be loading lots of
data within those new created dynamic tasks?


Ahmed.
Quote:
-----Original Message-----
Did you setup a workflow so that the new tasks would
execute after this initial task was finished?

Not sure you had to remove tasks and steps first. Just
set up your shell tasks with proper workflow and populate
them with requirted data.

Ken

'************************************************* *********
************
' Visual Basic ActiveX Script
'************************************************* *********
**************

Function Main()
Dim objPackage
Dim objStep
Dim objTask
Dim objScripTask
Dim Index
Dim taskname
Dim stepname


Set objPackage = DTSGlobalVariables.Parent
For Each objTask in objPackage.Tasks

For Index = 1 to 4
taskname = "AXScr_Task" & Index

IF objTask.Name = taskname Then

objPackage.Tasks.Remove(taskname)
End If
Next
Next



For Each objStep in objPackage.Steps
For Index = 1 to 4
stepname = "AXScr_Step" & Index
IF objStep.Name = stepname Then
objPackage.Steps.Remove(stepname)
End If
Next
Next
'create step and task, specify script, func name and
language


DTSGlobalVariables("GlobalOne").Value = 3

For Index = 1 to 4
Set objStep = objPackage.Steps.New
Set objTask = objPackage.Tasks.New("DTSActiveScriptTask")
Set objScripTask = objTask.CustomTask
objScripTask.Name = "AXScr_Task" & Index


objScripTask.ActiveXScript = _
"Function Main()" & vbCrLf & _
"MsgBox ""Hello World "" " & vbCrLf & _
"If DTSGlobalVariables( ""GlobalOne"" ) > 0 Then"
& vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Success" &
vbCrLf & _
"Else" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Failure" &
vbCrLf & _
"End If" & vbCrLf & _
"End Function"

objScripTask.FunctionName = "Main"

objScripTask.ScriptLanguage = "VBScript"

'link step to task to package

objStep.TaskName = objScripTask.Name
objStep.Name = "AXScr_Step" & index

objPackage.Steps.Add objStep
objPackage.Tasks.Add objTask
Next
objPackage.FailOnError = False

Set taskname = Nothing
Set stepname = Nothing
Set objPackage = Nothing
Set objStep = Nothing
Set objTask = Nothing
Set objScripTask = Nothing

Main = DTSTaskExecResult_Success

End Function




Reply With Quote
  #4  
Old   
Ahmed Zayan
 
Posts: n/a

Default ActiveXScriptTask not running as described! - 09-10-2003 , 05:14 PM



Actually, I unchecked the "Execute on main.." because I
want the tasks to run on a spawned thread.
Do I need to do any cleanup in those new tasks?


Ahmed.
Quote:
-----Original Message-----
Hi Ken,

I added the steps and it works now, i also opened the
workflow of this Task and checked "Execute on Main
Package
thread".

My question is those tasks should be executed on their
own
thread, concurrent operation. I will be loading lots of
data within those new created dynamic tasks?


Ahmed.
-----Original Message-----
Did you setup a workflow so that the new tasks would
execute after this initial task was finished?

Not sure you had to remove tasks and steps first. Just
set up your shell tasks with proper workflow and
populate
them with requirted data.

Ken

'************************************************* ********
*
************
' Visual Basic ActiveX Script
'************************************************* ********
*
**************

Function Main()
Dim objPackage
Dim objStep
Dim objTask
Dim objScripTask
Dim Index
Dim taskname
Dim stepname


Set objPackage = DTSGlobalVariables.Parent
For Each objTask in objPackage.Tasks

For Index = 1 to 4
taskname = "AXScr_Task" & Index

IF objTask.Name = taskname Then

objPackage.Tasks.Remove(taskname)
End If
Next
Next



For Each objStep in objPackage.Steps
For Index = 1 to 4
stepname = "AXScr_Step" & Index
IF objStep.Name = stepname Then
objPackage.Steps.Remove(stepname)
End If
Next
Next
'create step and task, specify script, func name and
language


DTSGlobalVariables("GlobalOne").Value = 3

For Index = 1 to 4
Set objStep = objPackage.Steps.New
Set objTask = objPackage.Tasks.New("DTSActiveScriptTask")
Set objScripTask = objTask.CustomTask
objScripTask.Name = "AXScr_Task" & Index


objScripTask.ActiveXScript = _
"Function Main()" & vbCrLf & _
"MsgBox ""Hello World "" " & vbCrLf & _
"If DTSGlobalVariables( ""GlobalOne"" ) > 0 Then"
& vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Success" &
vbCrLf & _
"Else" & vbCrLf & _
vbTab & "Main = DTSTaskExecResult_Failure" &
vbCrLf & _
"End If" & vbCrLf & _
"End Function"

objScripTask.FunctionName = "Main"

objScripTask.ScriptLanguage = "VBScript"

'link step to task to package

objStep.TaskName = objScripTask.Name
objStep.Name = "AXScr_Step" & index

objPackage.Steps.Add objStep
objPackage.Tasks.Add objTask
Next
objPackage.FailOnError = False

Set taskname = Nothing
Set stepname = Nothing
Set objPackage = Nothing
Set objStep = Nothing
Set objTask = Nothing
Set objScripTask = Nothing

Main = DTSTaskExecResult_Success

End Function


.


Reply With Quote
  #5  
Old   
Darren Green
 
Posts: n/a

Default Re: ActiveXScriptTask not running as described! - 09-10-2003 , 05:19 PM



In article <009801c377e6$e01c7290$a101280a (AT) phx (DOT) gbl>, Ahmed Zayan
<ahmed.zayan (AT) boeing (DOT) com> writes
Quote:
Hi Ken,

I added the steps and it works now, i also opened the
workflow of this Task and checked "Execute on Main Package
thread".

My question is those tasks should be executed on their own
thread, concurrent operation. I will be loading lots of
data within those new created dynamic tasks?


Adding and removing tasks dynamically at run-time is not a good idea,
and neither is it supported I believe. Can you not create a package and
change the tasks content or workflow as Ken suggests.


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #6  
Old   
Ahmed Zayan
 
Posts: n/a

Default Re: ActiveXScriptTask not running as described! - 09-10-2003 , 11:12 PM



The example I sent works fine. This is the second time I
hear the same advice against creating dynamic tasks.
Can you explain why, and how I implement the same example
I posted? Each task supposes to be doing a different
function, loading different table.

Ahmed Zayan.
Quote:
-----Original Message-----
In article <009801c377e6$e01c7290$a101280a (AT) phx (DOT) gbl>,
Ahmed Zayan
ahmed.zayan (AT) boeing (DOT) com> writes
Hi Ken,

I added the steps and it works now, i also opened the
workflow of this Task and checked "Execute on Main
Package
thread".

My question is those tasks should be executed on their
own
thread, concurrent operation. I will be loading lots of
data within those new created dynamic tasks?



Adding and removing tasks dynamically at run-time is not
a good idea,
and neither is it supported I believe. Can you not create
a package and
change the tasks content or workflow as Ken suggests.


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server
professionals
http://www.sqlpass.org

.


Reply With Quote
  #7  
Old   
Darren Green
 
Posts: n/a

Default Re: ActiveXScriptTask not running as described! - 09-11-2003 , 01:09 PM



In article <032d01c3781a$ef10e310$a101280a (AT) phx (DOT) gbl>, Ahmed Zayan
<ahmed.zayan (AT) boeing (DOT) com> writes
Quote:
The example I sent works fine. This is the second time I
hear the same advice against creating dynamic tasks.
Can you explain why, and how I implement the same example
I posted? Each task supposes to be doing a different
function, loading different table.

I though the example you sent had a problem which is why you posted it,
or have a missed the point?

I was advised by a member of the SQL product team, and I'm sure they
have posted similar warnings on the newsgroup, but I couldn't find it
just now. I trust their advice and pass it on when I can, even if I can
not fully explain it.

You have several units of work, so why not use either workflow to turn
on or off pre-existing tasks, coupled with changing those existing tasks
at run-time if required. For a more modular approach you could break
the units of work down into multiple packages and call a package from
another package.


--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #8  
Old   
Ahmed Zayan
 
Posts: n/a

Default Re: ActiveXScriptTask not running as described! - 09-11-2003 , 03:13 PM




Quote:
-----Original Message-----
In article <032d01c3781a$ef10e310$a101280a (AT) phx (DOT) gbl>,
I though the example you sent had a problem which is why
you posted it,
or have a missed the point?

Sorry Dareen, I later sent script that worked.

Quote:
I was advised by a member of the SQL product team, and
I'm sure they
have posted similar warnings on the newsgroup, but I
couldn't find it
just now. I trust their advice and pass it on when I can,
even if I can
not fully explain it.

You have several units of work, so why not use either
workflow to turn
on or off pre-existing tasks, coupled with changing those
existing tasks
at run-time if required. For a more modular approach you
could break
the units of work down into multiple packages and call a
package from
another package.

Maybe I could not explain what I am trying to do clearly.
The idea is the task, the one I sent as an example will
acts like controller by monitoring a job queue and
assigned each task, max of four, from this queue to each
task to execute.

Ahmed.

Quote:
--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server
professionals
http://www.sqlpass.org

.


Reply With Quote
  #9  
Old   
Darren Green
 
Posts: n/a

Default Re: ActiveXScriptTask not running as described! - 09-15-2003 , 12:33 PM



In article <0e2f01c378a1$288a0eb0$a501280a (AT) phx (DOT) gbl>, Ahmed Zayan
<ahmed.b.zayan (AT) boeing (DOT) com> writes
Quote:
snip

Maybe I could not explain what I am trying to do clearly.
The idea is the task, the one I sent as an example will
acts like controller by monitoring a job queue and
assigned each task, max of four, from this queue to each
task to execute.

Ahmed.


Ahmed,

You mention queue, so perhaps an MQ queue, with the DTS MQ task waiting
for a message? Not sure of your frequency, but you could schedule 4 jobs
all of the same package to ensure up to four instances of the same
package are ready and waiting for queue messages.

Alternatively you could use an ActiveX Script to process the queue if
appropriate, and load an existing package, change any properties, such
as global variables or task properties, then call the package execute
method.

Both of these use a pre-built package for convenience.

Any use?
--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



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.