Binds a place holder in a SQL statement. The bound place holder — identified by number — is then accessible through the OdbcSet and OdbcGet functions. This function must be called after preparing the SQL statement and before calling the OdbcSet functions.
ODBC.bdh
OdbcBind( in cCursor : cursor, in sPlaceholder : string, in nDataType : number optional, in nSize : number optional, in nSqlDataType : number optional, in nSqlSize : number optional, in nPrecision : number optional, in nParamType : number optional ): boolean;
true if successful
false otherwise
Parameter | Description |
---|---|
cCursor | Cursor associated with a database connection. |
sPlaceholder |
Location of the place holder in the SQL statement. This parameter must include the preceding colon identifying it as a place holder. Place holders are numbered sequentially from left to right, starting with 1, as they appear in the SQL statement. |
nDataType |
C language data type of the place holder (optional). This parameter must be set to one of the following values:
|
nSize | Size of the C language data type in bytes (optional). |
nSqlDataType |
SQL data type of the place holder being bound (optional). This parameter must be set to one of the following values:
|
nSqlSize | Size of the SQL data type in bytes (optional). |
nPrecision | Number of digits to the right of the decimal point (optional). |
nParamType |
Type of place holder being bound (optional). This parameter must be set to one of the following values:
|
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); OdbcPrepare(cCursor, sqlInsert); 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); OdbcExecute(cCursor); OdbcClose(cCursor, SQL_DROP); OdbcCommit(hDbc); OdbcDisconnect(hDbc); OdbcFree(hDbc); OdbcFree(hEnv); end TMain; dclsql sqlInsert: INSERT INTO persons (name, age) VALUES (?, ?);