ODBC Server Reference Manual

Stored Procedures
HP NonStop ODBC Server Reference Manual429151-002
5-27
SPELIB Interface
Encode “end statement” and “end procedure” messages. After all the rows
have been returned, the stored procedure must encode an “end statement”
message to indicate the SQL statement has been completed. As this is the end
of the stored procedure, an “end procedure” message must also be encoded.
*--------------------------------------------------------
* Every SQL statement should end with an
* END_STATEMENT message
*--------------------------------------------------------
ENTER C "ENCODE_END_STATEMENT" IN C-PROC USING
SP-ENV,
WS-MAX-LEN,
SQLCA,
SP-BUFFER,
SP-REPLY
GIVING WS-RC.
*--------------------------------------------------------
* Every stored procedure should end with an
* END_PROC message
*--------------------------------------------------------
ENTER C "ENCODE_END_PROC" IN C-PROC USING
SP-ENV,
WS-MAX-LEN,
SP-BUFFER,
SP-REPLY
GIVING WS-RC.
5. The following code is taken from the file SAMPLEC; it is written in C. The external
declaration is set up for the COBOL85 stored procedure:
_cobol void DEPT9000(char*, char*, char*, char*, char*);
6. Register the stored procedure, DEPT9000, by calling the shell function
REGISTER_SPE. In this case, the stored procedure name is DEPT9000; the
procedure function is the PROGRAM-ID, which is DEPT9000. There are no
initialization or clean-up procedures for COBOL85 stored procedures.
REGISTER_SPE( "DEPT9000"
, 8
, DEPT9000
, NULL
, NULL
);
SPELIB Interface
The SPELIB function library allows Pathway server programs to execute and reply to
stored procedure execution requests.
All functions in the SPELIB require at least one parameter, the SPE environment
object. Server programmers must allocate space for this structure. The information
contained within it is used by the SPELIB during encoding and decoding. Programmers
should not attempt to directly manipulate the data stored in the environment structure.