This example shows how the rpc_execute callback function in GATECBS.C sends a remote stored procedure to, and receives results from, a remote database.
DBPROCESS *rmtproc; // DBPROCESS pointer
int i; // Index variable
short params;
short retparam;
short *paramarray;
DBCHAR complete_rpc_name[4 * (MAXNAME 1)];//Database.owner.name;#
rmtproc = ((REMOTE_DBMS *)srv_getuserdata(srvproc))->dbproc;
paramarray = ((REMOTE_DBMS *)srv_getuserdata(srvproc))->retparams;
dbrpcinit(rmtproc, complete_rpc_name,
(DBUSMALLINT)srv_rpcoptions(srvproc));
// Set up any RSP parameters.
params = srv_rpcparams(srvproc);
retparam = 1;
for (i = 1; i <= params; i+)
{
rpc_paramname = srv_paramname(srvproc, i, (int *)NULL);
if (!strlen(rpc_paramname))
rpc_paramname = NULL;
rpc_paramstatus = (BYTE)srv_paramstatus(srvproc, i);
rpc_paramtype = srv_paramtype(srvproc, i);
rpc_parammaxlen = srv_parammaxlen(srvproc, i);
rpc_paramlen = srv_paramlen(srvproc, i);
rpc_paramdata = srv_paramdata(srvproc, i);
dbrpcparam(rmtproc,rpc_paramname,rpc_paramstatus,rpc_paramtype,
rpc_parammaxlen,rpc_paramlen, rpc_paramdata);
// Not all parameters are return parameters. Map each return
// parameter to its original parameter to later reset the return
// value of the correct return parameters in "handle_results()".
if((BYTE)srv_paramstatus(srvproc, i) & SRV_PARAMRETURN) {
paramarray[retparam] = i;
retparam+;
}
dbrpcsend(rmtproc);
dbsqlok(rmtproc);
handle_results(rmtproc, srvproc);
return (SRV_CONTINUE);