Sending RPC commands

An RPC command invokes an Adaptive Server stored procedure or an Open Server registered procedure, passing parameters in their declared datatypes.

The following table compares the Client-Library and DB-Library call sequences to define and send an RPC command:

Table 5-6: DB-Library vs. Client-Library—sending RPC commands

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.