An RPC command invokes an Adaptive Server Enterprise stored procedure or an Open Server registered procedure, passing parameters in their declared datatypes.
Table 5-6 compares the Client-Library and DB-Library call sequences to define and send an RPC command:
DB-Library routines |
DB-Library functionality |
Client-Library routines |
Client-Library functionality |
---|---|---|---|
(none) |
(none) |
ct_cmd_alloc( connection, cmd_pointer) |
Allocate a CS_COMMAND structure. |
dbrpcinit(dbproc, rpc_name, option) |
Initialize an RPC. option can be DBRPCRECOMPILE or 0. |
ct_command(cmd, CS_RPC_CMD, rpc_name, buflen, option) |
Initiate an RPC command. option can be CS_RECOMPILE, CS_NO_RECOMPILE, or CS_UNUSED. A value of 0 in the DB-Library program maps to CS_UNUSED or CS_NO_RECOMPILE. |
dbrpcparam( dbproc, paramname, status, type, maxlen, datalen, data)
|
Add a parameter to an RPC. |
ct_param or ct_setparam(cmd, datafmt, data, datalen, indicator) |
Define an RPC parameter. |
dbrpcsend( dbproc) |
Send an RPC call to the server for execution. |
ct_send(cmd) |
Send a command to the server for execution. |
The use of ct_param for RPC commands is very similar to the use of dbrpcparam. Most of dbrpcparam’s parameters map to fields in the CS_DATAFMT structure that is passed as ct_param’s datafmt parameter.
dbrpcparam’s paramname, status, type, and maxlen parameters map to fields in the CS_DATAFMT structure taken as ct_param’s datafmt parameter.
A dbrpcparam call specifies a null value by passing datalen as 0. A ct_param call specifies a null value by passing indicator as -1.