Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Return error code and error message when running a procedure

634367Oct 20 2010 — edited Oct 22 2010
Hi all

I need to run an oracle stored procedure in a job and I would like to know how to call it and how to trap an error code when the procedrue faiils. The equivalent of sys.exit(1) in Python

These areError trapping source code examples for .net and Python. How can I do something similar with an Oracle procedure?


Module Module1

Sub Main()
Try
‘<your code>
Catch ex As Exception
System.Environment.ExitCode = 1 'General Exception Error
Console.WriteLine(ex.Message)
End Try
End Sub

End Module



Method 2
Example of Error trapping in Python:

# Python sample of a function that calls the Trap.cmd command

import win32api, os, sys

def CreateErrorFlag(aJobName):
try:
commandLine = "C:\Trigger\trap.cmd " + aJobName
aresult = os.system(commandLine)
if aresult > 0:
sys.exit(1)
except:
return (aresult)
print "error"
sys.exit(1)


CreateErrorFlag("J123456")
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2010
Added on Oct 20 2010
3 comments
536 views