Adds text to the DBPROCESS command buffer.
RETCODE dbcmd (
PDBPROCESS dbproc,
LPCSTR cmdstring );
SUCCEED or FAIL.
This function adds text to the command buffer in the DBPROCESS structure. It adds to the existing command buffer; it doesn’t delete or overwrite the current contents except after the buffer has been sent to SQL Server. The user can call dbcmd repeatedly. Note that sequential calls are concatenated; the application must include any necessary blanks between the end of one line and the beginning of the next.
After a call to dbsqlexec or dbsqlsend, the first call to either dbcmd or dbfcmd automatically clears the command buffer before the new text is entered. If this situation is undesirable, set the DBNOAUTOFREE option. When DBNOAUTOFREE is set, the command buffer is cleared only by a call to dbfreebuf.
The dbfcmd function is a related function. Unlike dbcmd, dbfcmd takes additional parameters and interprets cmdstring as a format string that is passed to sprintf along with any additional parameters.
This example shows how to use dbcmd to build up a multiple-line SQL statement:
DBPROCESS *dbproc;
dbcmd(dbproc, "SELECT name FROM sysobjects");
dbcmd(dbproc, " WHERE id < 5");
dbcmd(dbproc, " AND type='S'");
Note the leading spaces in the second and third calls to dbcmd. Leading spaces are needed to properly concatenate the entire command string.
Bulk-Copy Functions | dbsetopt |
dbfcmd | dbsqlexec |
dbfreebuf | dbsqlsend |
DB-Library Options |