dbcmd

Adds text to the DBPROCESS command buffer.

Syntax

RETCODE dbcmd (
PDBPROCESS
dbproc,
LPCSTR
cmdstring );

where

dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ SQL Server process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
cmdstring
Is a null-terminated character string to be copied into the command buffer.

Returns

SUCCEED or FAIL.

Remarks

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.

Example

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.

See Also

dbfcmd, dbfreebuf, dbsqlexec, dbsetopt, dbsqlsend; Bulk-Copy Functions and DB-Library Options