ct_send_params

Description

Send command parameters in batches.

Syntax

CS_RETCODE ct_send_params(
  CS_COMMAND *cmd, 
  CS_INT reserved)

Parameters

cmd

A pointer to the CS_COMMAND structure.

reserved

Set to CS_UNUSED. This is a placeholder reserved for possible future use.

Returns

ct_send_params returns:

Returns

Indicates

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

Reusing the bound parameter buffer: No rebind.

CS_CHAR linedata[MAX_LINE];
CS_UINT linenum;
retcode = ct_command(cmd, CS_LANG_CMD, sqlcommand, CS_NULLTERM, CS_END);
...
retcode = ct_setparam(cmd, &datafmt2, &linedata, &linelen, &gooddata);
...
retcode = ct_setparam(cmd, &datafmt1, &linenum, &unused, &gooddata);
...
while (fgets(linedata, sizeof(linedata), file) != NULL)
{
   linenum++;
   /*
   ** Send the parameters. This also starts sending the command if
   ** it's the first set of parameters.
   */
   retcode = ct_send_params(cmd, CS_UNUSED);
   ...
}
retcode = ct_send(cmd);
...
retcode = ex_handle_results(cmd);
...

Example 2

Rebinding the parameters with ct_setparam(cmd, NULL, ..)

typedef struct _my_data
{
   CS_INT number;
   CS_CHAR *string;
} MY_DATA;
MY_DATA da[];
...
retcode = ct_dynamic(cmd, CS_EXECUTE, dyn_id, CS_NULLTERM, NULL,
   CS_UNUSED);
...
retcode = ct_setparam(cmd, &datafmt1, NULL, &unused, NULL);
retcode = ct_setparam(cmd, &datafmt2, NULL, NULL, NULL);
...
for (i = 0; i < count; i++)
{
   printf("Sending: %i, %s\n", da[i].number, da[i].string);
   retcode = ct_setparam(cmd, NULL, &da[i].number, &unused, &gooddata);
   ...
   retcode = ct_setparam(cmd, NULL, da[i].string, &nullterm, &gooddata);
   ...
   retcode = ct_send_params(cmd, CS_UNUSED);
   ...
}
retcode = ct_send(cmd);
...
retcode = ex_handle_results(cmd);
...

Usage

A call to this function sends the parameters indicated earlier using ct_param() or ct_setparam(). To stop sending parameters, use a ct_send() call after the last ct_send_params() call. This signals the end of the parameters and completes the current command.