HPlogo ALLBASE/SQL Advanced Application Programming Guide: HP 3000 MPE/iX Computer Systems > Chapter 5 Using Procedures in Application Programs

Returning a Return Status Code

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

A return status code is an integer value returned from a procedure not invoked by a rule. You define the meaning of the code within the procedure. You could use the return status code to indicate the success or failure of the procedure, the value of SQLCODE, or some other flag.

You must declare an integer host variable in your application to hold the code, and use the host variable as a part of the EXECUTE PROCEDURE statement. Any legal host variable name can be used as a return code name. The following example in C uses an integer host variable named Status:

   EXEC SQL EXECUTE PROCEDURE :Status =  

      Process12(:OpName :OpNameInd, :Shift :ShiftInd, :FailureType);

   if(sqlca.sqlcode==0) {

      if(Status==0) printf("Failure type entered\n");

      else printf("Failure type not entered. INSERT failed\n");

      }

A similar example in COBOL uses an integer host variable named RETCODE:

   EXEC SQL EXECUTE PROCEDURE {{:RETCODE =}} PROCESS12 (:OPERATOR :OPERATORIND,

        :SHIFT :SHIFTIND, :FAILURETYPE) END-EXEC.

   IF SQLCODE IS ZERO THEN

      IF RETCODE IS ZERO THEN

         DISPLAY "FAILURE TYPE ENTERED."

      ELSE 

         DISPLAY "FAILURE TYPE NOT ENTERED. INSERT FAILED."

      END-IF

   END-IF.

On return from the execution of the procedure, you first test SQLCODE, and if it is zero, you then test the value of the return code. If SQLCODE is not zero, the return code is undefined, since the procedure failed to execute properly.

Feedback to webmaster