A client application can call a stored procedure on an Adaptive Server or an Open ServerConnect transaction running in a separate CICS or IMS region.
A client application can call a stored procedure or mainframe transaction in one of two ways:
By executing a SQL language request (for example, “execute myproc”).
By making an RPC.
RPCs have a few advantages over execute statements:
An RPC can be used to execute an Adaptive Server stored procedure or any Open ServerConnect transaction.
A SQL language request can only be used to execute an Adaptive Server stored procedure or a specially written Open ServerConnect language transaction.
When sending a request to Adaptive Server, it is simpler and faster to accommodate stored procedure return parameters if the procedure is invoked with an RPC instead of a language request.
A server can execute a stored procedure or transaction residing on another server. This might occur when a stored procedure being executed on one Adaptive Server contains an execute statement for a stored procedure on another Adaptive Server. The execute command causes the first server to log into the second server and execute the remote procedure. This is called a server-to-server RPC. It happens without any intervention from the application, although the application can specify the remote password that the first server uses to log into the second.
A server-to-server RPC also occurs when an application sends a request to execute a stored procedure that does not reside on the server to which it is directly connected.
SQL commands contained in a stored procedure that is
executed as the result of a server-to-server remote procedure call
cannot be rolled back.
The following functions relate to RPCs:
CTBREMOTEPWD sets and clears the passwords that are used when logging into a remote server (This feature is not available for calls to Open ServerConnect).
CTBCOMMAND initiates an RPC.
CTBPARAM defines parameters for an RPC.
CTBSEND sends an RPC.
CTBRESULTS, CTBBIND, and CTBFETCH process remote procedure results.
In addition to results generated by the SQL statements they contain, Adaptive Server stored procedures and Open ServerConnect transactions that are executed via an RPC:
Can generate a return parameter result set.
Always generate a return status result set.
All types of results—rows, status, and parameters—can be processed using CTBRESULTS, CTBBIND, and CTBFETCH.