ODBC Server Reference Manual
Stored Procedures
HP NonStop ODBC Server Reference Manual—429151-002
5-20
Developing a Stored Procedure in COBOL
/* ------------------------------------------------------
Every stored procedure should end with an END_PROC
message
---------------------------------------------------- */
rc = encode_end_proc( env);
if (rc != SPELIB_OK)
*reply_err = rc;
3. Create Clean-Up Routine
This is the routine that will be called when the stored procedure server process is
stopping. Typically, this routine is used for freeing up resources allocated for this
stored procedure, as follows:
boolean dispose_SPE_21(void)
{
boolean rc = SUCCESS
dispose(sdai21);
dispose(sdao21);
dispose(sdan21);
dispose(colnames21);
}
4. Include the header file generated for the routines INITIALIZE_SPE_21,
SELECT_INPUT_DEPT, and DISPOSE_SPE_21 in the source file for the main
routine (CSAMPLEC).
#pragma page "Example Stored Procedure, CSAMPLEC"
#pragma sql
#include <stdio.h> nolist
#include "cshell.h" nolist
/* source in header file for shell routines */
#include "sp21.h" nolist
/* source in header for for stored procedure */
5. Register the new procedure by adding a call to the routine SPE_REGISTER.
main()
{
...
register_spe( "select_input_dept" /*stored procedure name*/
, 17 /*procedure name length*/
, select_input_dept /*procedure function*/
, initialize_SPE_21 /*initialization for proc*/
, dispose_SPE_21 /*cleanup for procedure*/
);
Developing a Stored Procedure in COBOL
The basic development model for COBOL is similar to that for C, as described in the
preceding subsection. There are differences for COBOL development, however.
The basic development steps are described as follows. A more detailed description of
how to create the code for the stored procedure appears later in this subsection.
1. Create the stored procedure (DEPT9000).