Send command parameters in batches.
CS_RETCODE ct_send_params( CS_COMMAND *cmd, CS_INT reserved)
A pointer to the CS_COMMAND structure.
Set to CS_UNUSED. This is a placeholder reserved for possible future use.
ct_send_params returns:
Returns |
Indicates |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
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); ...
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); ...
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.
The first ct_send_params() call sends the actual command, the parameter formats for all parameters, and the first set of parameters to the server. Subsequent calls only send more parameters without format.
The network buffer containing the parameters gets flushed during every call to ct_send_params() so that the server can start processing the command.
Unlike ct_send(), ct_send_params() does not end the current command. You can call ct_send_params() repeatedly to send multiple sets of parameters.
The handling of the results starts only after a ct_send() call to complete the command. If ct_results() is called before ct_send(), an error results.