ODBC Server Reference Manual

Stored Procedures
HP NonStop ODBC Server Reference Manual429151-002
5-7
Server Logic Sequence
messages. The SPELIB functions do not perform any actual I/O ($RECEIVE, OPEN,
WRITE and REPLY handling) between the NonStop ODBC Server and the Pathway
server class program. However, a sample Pathway server program has been provided
with the NonStop ODBC Server product that includes a set of routines for handling
$RECEIVE and a set of SPELIB shell routines for handling call-back processing. In
addition, the source code for three sample stored procedures that access the NonStop
SQL/MP sample database are released with this product.
When developing a stored procedure, you have two options (option 1 is the
recommended approach):
1. Develop the stored procedure using the sample Pathway server program and the
set of shell routines provided with the sample server program. These routines
mirror the SPELIB functions, but are integrated into the sample Pathway server
program and remove the need for you to do call-back processing and to perform
I/O.
2. Develop the stored procedure using the SPELIB library functions. The stored
procedure can then be embedded in the sample Pathway server program, or you
can provide your own Pathway server code.
The differences between these two options are as follows:
Call-back handling—the major difference is that the shell routines in the sample
Pathway server program insulate you from having to deal with call-back
processing. The routines automatically initiate a call-back if the IPC buffer
becomes full. When using the SPELIB functions directly, you are responsible for
handling this. However, by using the SPELIB functions directly, you have control
over when to initiate call-back.
Use of the sample server—when using the shell routines, you must use the sample
server. When using the SPELIB functions directly, you can use your own server
code. The sample server is intended as a starting point; you can then change it to
suit your own purposes. (SPELIB functions and shell routines are listed at the end
of this subsection)
Server Logic Sequence
The Pathway server program executing the stored procedures should perform the
following functions (see the “Sample Stored Procedures” subsection for more details):
Read $RECEIVE to receive the IPC message from the NO
Decode the message by calling the sample shell routines or the SPELIB functions.
Allocate memory for input parameters and output results.
Call a stored procedure to perform work.
Encode the reply message by calling the sample shell routines or the SPELIB
functions.