ODBC Server Reference Manual
Stored Procedures
HP NonStop ODBC Server Reference Manual—429151-002
5-57
Fault-Tolerant Programming
A Pathway server class program can explicitly abort a transaction or cause a
transaction to be aborted. As a result, it is necessary for the NonStop ODBC Server to
check transaction status after the server class program replies to a stored procedure
request.
For a server class program that deals with nonaudited NonStop SQL/MP DDL, or
would like to start its own transaction, the server class program should check whether
it inherits a transaction from the NonStop ODBC Server. The server class program can
call the system function RESUMETRANSACTION to suspend and resume the
transaction, if necessary.
The following describes the basic transaction model, in which a Pathway server class
program inherits a transaction from the NonStop ODBC Server, executes SQL
statements, then issues a REPLY. The NonStop ODBC Server then performs an
ABORTTRANSACTION statement or a COMMITTRANSACTION statement, as
appropriate.
A Pathway server class program can suspend the inherited transaction, and can start
transactions of its own. Because transactions started by the server class are
transparent to the NonStop ODBC server, it commits or aborts only the transactions
started by itself.
If the call-back mechanism is used, it is recommended that SETMODE
(requestor_file_num, 117, 1) be called (after OPEN) to suppress attaching transid to
WRITE or WRITEREAD.
The sample server program supplied with the NonStop ODBC Server handles
activation of the transaction.
Fault-Tolerant Programming
The NonStop ODBC server is not a process pair and does not retry ServerClass_Send
requests. If a client loses a session with the NonStop ODBC Server, it is the client’s
responsibility to determine the state left by the server class process (it is possible for a
ServerClass_Send to be completed and for the NonStop ODBC Server to commit the
transaction before the session is lost).
NonStop ODBC Server
...
BEGINTRANSACTION (&transid)
PATHSEND(buffer, messagelen
.
.
.
.
.
.
/* PATHSEND COMPLETE
*/?RESUMETRANSACTION (transid);
/* Check transaction status */
/* abort or commit transaction */
Pathway Server
OPEN ($RECEIVE)
READUPDATE from $RECEIVE
/* Get inherited transaction. */
LASTRECEIVE (&msg_tag);
/* Activate transaction. */
ACTIVATERECEIVETRANSID (msg_tag);
/* Execute SQL statements here. */
REPLY ()