Prepares and executes a SQL statement. This function is the fastest way to submit a SQL statement that is to be executed only once to the data source. Because the SQL statement is both prepared and executed in the same step, the specified SQL statement must be reprepared each time it is executed.
ODBC.bdh
OdbcExecDirect( in cCursor : cursor, in sqlStatement : sql, in nArraySize : number optional ): boolean;
true if successful
false otherwise
Parameter | Description |
---|---|
cCursor | Cursor associated with a database connection. |
sqlStatement | SQL statement to prepare and execute. |
nArraySize | Size of the data array. Arrays are used to process multiple rows of data in a single execute operation. |
var hEnv, hDbc : number; cCursor : cursor; dcltrans transaction TMain begin OdbcAlloc(SQL_HANDLE_ENV, hEnv); OdbcAlloc(SQL_HANDLE_DBC, hDbc, hEnv); OdbcConnect(hDbc, "DSN=database;UID=user;PWD=pass;"); OdbcOpen(cCursor, hDbc); OdbcBind(cCursor, ":1", SQL_C_CHAR, 32); OdbcBind(cCursor, ":2", SQL_C_LONG); OdbcSetString(cCursor, ":1", "Bob", 1); OdbcSetInt(cCursor, ":2", 25, 1); OdbcSetString(cCursor, ":1", "Marcy", 2); OdbcSetInt(cCursor, ":2", 33, 2); OdbcExecDirect(cCursor, sqlInsert); OdbcClose(cCursor, SQL_DROP); OdbcCommit(hDbc); OdbcDisconnect(hDbc); OdbcFree(hDbc); OdbcFree(hEnv); end TMain; dclsql sqlInsert: INSERT INTO persons (name, age) VALUES (?, ?);