Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Error Handling in a sub to set Main = DTSFailure

Author  Topic 

JStandard
Starting Member

3 Posts

Posted - 2006-03-17 : 14:15:26
Greetings,

I have a DTS with a VBScript component that has a Function Main() and a Sub Test() in it.

Is there any way I can call the sub within main and using error handling, set Main = DTSTaskExecResult_Failure?

Ex.

Sub TestArray(aTest)
On Error Resume Next
aTest(1,2) = "This is out of bounds"
If err.number <> 0 Then
Main = DTSTaskExecResult_Failure
' Ideally DTS would end right here because of failure
End If
On Error Goto 0
End Sub

Function Main()
Dim aTest(1,1), bTest(1,1)
TestArray aTest

' Other Stuff
TestArray bTest

Main = DTSTaskExecResult_Success
End Function


So in the above example, I am basically attempting to halt the DTS when I encountered an error in a specific part of the Sub TestArray.

This would allow me to be able to use this function at multiple points within the code, without having to encapsulate it in an error handling block each time I want to call the function.

To put it in Java terms, if I am calling a method from within a method, no matter where I am, I can use the System.Out.Exit() to cause the application to end prematurely. I am looking for analagous functionality in DTS/VBScript.

Is there anyway I can accomplish having the Sub cause the Main function to fail in a VBScript DTS Task? Is there a better way to do this?

Any help is much appreciated.

Thanks kindly,
- Jeff
   

- Advertisement -