|
Kelly Jones wrote:
We have a situation where we need to call a Java program, have it do "it's thing", then pass a return code back to the calling program. The main point of the return code is to inform the calling program whether everything went OK. If the Java program bombs, we need to inform the caller that something bad happened and stop. Can someone provide an example how to do this?
When we need to do this, we create a Java Stored Procedure. The procedure can define the input and output parameters like this: CREATE PROCEDURE Libray.ProcName ( IN SomeVariable VARCHAR(25) , OUT ErrorCode Integer ) LANGUAGE JAVA NOT DETERMINISTIC MODIFIES SQL DATA EXTERNAL NAME 'com.yourcompany.ClassName!methodName' PARAMETER STYLE JAVA ; Your class goes in the /UserData/OS400/SQLLib/Function/ directory or is available through the classpath. Then your CL or RPG (or whatever) can call the stored procedure in a SQL statement just like it would any other stored procedure. This works well for us. The Java program can catch exceptions or handle different types of problems and return an appropriate error code. We always return 0 if there were no problems. ************************************************************************************************** The contents of this email and any attachments are confidential. They are intended for the named recipient(s) only. If you have received this email in error please notify the system manager or the sender immediately and do not disclose the contents to anyone or make copies. ** eSafe scanned this email for viruses, vandals and malicious content. ** **************************************************************************************************
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.