OdbcSetMode Function

Action

Sets the indicator for an item of a bound place holder or a result data column.

Include file

ODBC.bdh

Syntax

OdbcSetMode( in cCursor     : cursor ,
             in sIdentifier : string,
             in nMode       : number,
             in nIndex      : number optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
cCursor Cursor associated with a database connection.
sIdentifier Identifier of the place holder or the result data column. To identify a place holder, begin this parameter with a colon.
nMode

Indicator for the place holder or column item. This parameter must be set to one of the following values:

  • SQL_NULL_DATA. The data value associated with the place holder or result data column is NULL.

  • SQL_DATA_AT_EXEC. The data value must be sent to the data source at SQL statement execution time.

  • SQL_DEFAULT_PARAM. The default parameters of a stored procedure are used when calling a stored procedure.

  • SQL_IGNORE. The respective column is ignored when processing result data columns.

nIndex Array index for the place holder or column item whose indicator is to be set (optional). By default, this function sets the indicator for the first item.

Example

var
  hEnv, hDbc : number;
  cCursor : cursor;

dcltrans
  transaction TMain
  var
    sIdentifier : string;
    nRow        : number;
  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);
    OdbcSetMode(cCursor, ":1", SQL_DATA_AT_EXEC);
    OdbcSetMode(cCursor, ":2", SQL_DATA_AT_EXEC);
    OdbcExecute(cCursor);
    OdbcParamData(cCursor, sIdentifier, nRow);

    if sIdentifier = ":1" then
      OdbcSetString(cCursor, "", "Jim");
      OdbcParamData(cCursor);
      OdbcSetInt(cCursor, "", 25);
    elseif sIdentifier = ":2" then
      OdbcSetInt(cCursor, "", 25);
      OdbcParamData(cCursor);
      OdbcSetString(cCursor, "", "Jim");
    end;
    
    OdbcClose(cCursor, SQL_DROP);
    OdbcCommit(hDbc);
    OdbcDisconnect(hDbc);
    OdbcFree(hDbc);
    OdbcFree(hEnv);
  end TMain;

dclsql
  sqlInsert:
  INSERT INTO persons (name, age) VALUES (?, ?);