dbsqlexec

Description

Send a command batch to the server.

Syntax

RETCODE dbsqlexec(dbproc)
 
DBPROCESS     *dbproc;

Parameters

dbproc

A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server.

Returns

SUCCEED or FAIL.

The most common reason for failing is a SQL syntax error. dbsqlexec will also fail if there are semantic errors, such as incorrect column or table names. Failure occurs if any of the commands in the batch contains a semantic or syntax error. dbsqlexec also fails if previous results had not been processed, or if the command buffer was empty.

In addition, a runtime error, such as a database protection violation, can cause dbsqlexec to fail. A runtime error will cause dbsqlexec to fail:

If the command buffer contains multiple commands (and the first command in the buffer is ok), a runtime error will not cause dbsqlexec to fail. Instead, failure will occur with the dbresults call that processes the command causing the runtime error.

The situation is a bit more complicated for runtime errors and stored procedures. A runtime error on an execute command may cause dbsqlexec to fail, in accordance with the rule given in the previous paragraphs. A runtime error on a statement inside a stored procedure will not cause dbsqlexec to fail, however. For example, if the stored procedure contains an insert statement and the user does not have insert permission on the database table, the insert statement will fail, but dbsqlexec will still return SUCCEED. To check for runtime errors inside stored procedures, use the dbretstatus routine to look at the procedure’s return status, and trap relevant server messages inside your message handler.

Usage

See also

dbcmd, dbfcmd, dbnextrow, dbresults, dbretstatus, dbsettime, dbsqlok, dbsqlsend