The following code fragment illustrates sending a Client-Library language command. This fragment is from the ex01ct.c migration sample program:
CS_CONNECTION *conn;
CS_COMMAND *cmd;
... connection has been opened ...
/*
** Allocate a command structure.
*/
ret = ct_cmd_alloc(conn, &cmd);
EXIT_ON_FAIL(context, ret, "Could not allocate command structure."); /*
-- dbcmd(dbproc, "select name, type, id, crdate from sysobjects");
-- dbcmd(dbproc, " where type = ’S’ ");
-- dbcmd(dbproc, "select name, type, id, crdate from sysobjects");
-- dbcmd(dbproc, " where type = ’P’ ");
*/
/*
** Build up a language command. ct_command() constructs language,
** RPC, and some other server commands.
**
** Note that the application manages the language buffer: You
** must format the language string with stdlib calls before
** passing it to ct_command().
*/
strcpy(sql_string, "select name, type, id, crdate from sysobjects");
strcat(sql_string, " where type = ’S’ ");
strcat(sql_string, "select name, type, id, crdate from sysobjects");
strcat(sql_string, " where type = ’P’ ");
ret = ct_command(cmd, CS_LANG_CMD, (CS_VOID *) sql_string,
CS_NULLTERM,CS_UNUSED);
EXIT_ON_FAIL(context, ret, "Init language command failed."); /*
-- * Send the commands to Adaptive Server Enterprise and start execution. *
-- dbsqlexec(dbproc);
*/
/*
** Send the command. Unlike dbsqlexec(), ct_send() returns as
** soon as the command has been sent. It does not wait for
** the results from the first statement to arrive.
*/
ret = ct_send(cmd);
EXIT_ON_FAIL(context, ret, "Send language command failed.");
... deleted results processing code ...