ODBC Users` Manual

Add to My manuals
280 Pages

advertisement

ODBC Users` Manual | Manualzz

SQLExecute

SQLExecute

SQLExecute submits a prepared statement, using the current values of the parameter marker variables if any parameter markers exist in the statement.

Syntax

SQLRETURN SQLExecute (

SQLHSTMT stmt );

Arguments

Data Type

SQLHSTMT

Argument stmt

In/Out

Input

Description

Statement handle

Return Values

SQL_SUCCESS

SQL_SUCCESS_WITH_INFO

SQL_NO_DATA_FOUND

SQL_INVALID_HANDLE

SQL_ERROR

Description

The parameter marker can be included in a SQL statement string. The parameter marker specified by

‘?’ and designates the place of the parameters to be replaced as an application variable when SQLExecute () is called. SQLBindParameter () must bind each parameter marker with a corresponding application variable, and displays whether the data must be converted for transmission. All parameters must be bound before SQLExecute () is called.

SQLExecute() executes a statement prepared by SQLPrepare(). After the application processes or discards the results from a call to SQLExecute, the application can call SQLExecute() again with new parameter values

The command executed by SQLExecDirect () cannot be execute again by SQLExecute (). SQLPrepare

() must be called first.

In case SQLExecute () executes an UPDATE and DELETE statement that does not affect any row in the database, calling SQLExecute () will return SQL_NO_DATA. Use SQLRowCount() to check the number of record.

71 ODBC Functions

SQLExecute

If SQL_ATTR_PARAMSET_SIZE statement attribute is higher than 1 and the SQL statement has at least one parameter marker, SQLExecute () will execute an SQL statement once for a series of the parameters in the array indicated by the *Value argument upon calling of SQLBindParameter ().

Diagnosis

SQLSTATE

07006

Description

Restricted data type attribute violation

08003

08S01 Communication channel error

Comments

The column data within the result set must not be converted to the data type expressed in cType of SQLBind-

Col().

When stmt is not connected or the connection is released

The communication link between the driver and the database to which the driver was connected failed before the function completed processing.

HY000

HY090

General error

Invalid string or buffer length If SQLBindParameter () and the related parameters are NULL pointers, the parameter length is not 0 or

SQL_NULL_DATA. If the parameter designated with SQLBindParameter () is not the NULL pointer, C data type will be SQL_C_BINARY or

SQL_C_CHAR and the parameter length will be smaller than 0.

SQLExecute () can return all SQLSTATE data that are returned by SQLPrepare ().

Related Functions

SQLBindCol

SQLEndTran

SQLExecDirect

SQLFetch

SQLFreeStmt

SQLGetData

ODBC Users’ Manual 72

SQLPrepare

SQLSetStmtAttr

Example

See: $ALTIBASE_HOME/sample/SQLCLI/demo_ex2.cpp

See the examples of SQLBindParameter ().

SQLExecute

73 ODBC Functions

advertisement

advertisement

Table of contents