ODBC_SQLExecute

4D - Documentation   Français   English   German   4D ODBC PRO, Command Theme List   4D ODBC PRO, Command Alphabetical List   Back   Previous   Next

version 2004


ODBC_SQLExecute (stmtID) Longint

ParameterTypeDescription
stmtIDLongintStatement ID
Function resultLongintReturns the result of the MS ODBC API function
SQLExecute

Description

The ODBC_SQLExecute command executes a prepared statement, using the current values of the parameter marker variables if any parameter markers exist in the statement.

stmtID is a valid statement ID returned by ODBC_SQLAllocStmt.

For more information, please see the SQLExecute function in the MS ODBC API at http://msdn.microsoft.com/library/en-us/odbc/htm/odbcsqlexecute.asp.

Function Results

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NEED_DATA, SQL_STILL_EXECUTING, SQL_ERROR, SQL_NO_DATA, or SQL_INVALID_HANDLE.

If ODBC_SQLExecute returns SQL_NEED_DATA, you can use the ODBC_SQLParamData and ODBC_SQLPutData commands.

Example

The following method creates a bind with our data source's Employee table and its four fields specified by the ODBC_SQLPrepare command and then inserts the data defined in the ODBC_SQLBindParameter command once the statement is executed:

   $result:=ODBC_SQLPrepare ($statementID;"INSERT INTO Employee (ID, Name, Hire_Date, 
                              Current_Employee)VALUES (?, ?, ?, ?)")

   vEmployeeHireDate:=Current date
   vEmployeeID:=6
   vEmployeeFullname:="Betty Jones"
   vEmployeeCurrent:=True

   $result:=ODBC_SQLBindParameter ($statementID;1;1;SQL_SMALLINT ;0;0;->vEmployeeID)
   $result:=ODBC_SQLBindParameter ($statementID;2;1;SQL_CHAR ;10;0;->vEmployeeFullname)
   $result:=ODBC_SQLBindParameter ($statementID;3;1;SQL_TYPE_DATE ;0;0;->vEmployeeHireDate)
   $result:=ODBC_SQLBindParameter ($statementID;4;1;SQL_BIT ;0;0;->vEmployeeCurrent)

   $result:=ODBC_SQLNumParams ($statementID;$numparams)
   $result:=ODBC_SQLExecute ($statementID)

See Also

ODBC_SQLBindCol, ODBC_SQLBindParameter, ODBC_SQLGetDiagField, ODBC_SQLGetDiagRec, ODBC_SQLParamData, ODBC_SQLPrepare, ODBC_SQLPutData.


4D - Documentation   Français   English   German   4D ODBC PRO, Command Theme List   4D ODBC PRO, Command Alphabetical List   Back   Previous   Next