ODBC Server Reference Manual

Stored Procedures
HP NonStop ODBC Server Reference Manual429151-002
5-21
Developing a Stored Procedure in COBOL
a. For the main sample server code to be able to call a stored procedure, it must
be given the name of a function to call for that procedure. This function name is
set up when the stored procedure is configured into the sample server. For
COBOL procedures, the function name is the PROGRAM-ID of the module for
the procedure. An entry must be set up in the CONFIGURATION SECTION to
reference the shell routines (SHELLO), or the SPELIB routines (SPELIBO) if
the shell routines are not being used; alternatively, you can use a CONSULT
directive. You must also set up the WORKING-STORAGE for any SQLDA
structures, host variables, or other data items.
b. Set up the LINKAGE SECTION and PROCEDURE DIVISION to declare the
parameters passed from the main server program when this stored procedure
is invoked.
c. Provide an initialization routine for any setup to be performed when the stored
procedure is first invoked, such as performing a PREPARE/DESCRIBE to set
up the row descriptor information. See the 1000-INITIALIZE routine for some
sample code.
d. Write the main code, such as 2000-PROCESS-REQUEST and
3000-END-PROCESS.
e. Compile the module.
2. Add the stored procedure to the sample program (SAMPLEC).
a. Include the external declaration for the COBOL module; for example:
_cobol void DEPT9000(.....).
b. Register the new stored procedure in the server program by calling the function
REGISTER_SPE.
3. Build the new sample program.
a. Compile and rebind the sample program. See the file BINDFILE for some
sample BIND commands.
b. SQL compile the new sample program.
4. Set up the Pathway configuration for the new server. See EMP-DATA-MIX in the
file PATHIN for a sample configuration.
5. Register the stored procedure with the NonStop ODBC Server by using the
NOSUTIL command ADD PROCEDURE. See the command for adding the stored
procedure DEPT9000 in the file ADDSP.
6. Set up the sample database, if it is not already installed.
7. Execute the stored procedure.
a. Start the Pathway server; for example:
Pathmon /name $empsp/
Pathcom /in pathin/ $empsp