OdbcParamData Function

Action

Determines which data the script has to send to the data source.

When a Silk Performer script executes a SQL statement, the ODBC driver requests data when it encounters a data-at-execution parameter or column. This function then determines which data the script should send. Once the script knows what data to send, it must call the OdbcSet functions repeatedly until all the data-at-execution data has been sent to the data source.

Include file

ODBC.bdh

Syntax

OdbcParamData(
   in  cCursor     : cursor,
   out sIdentifier : string optional,
   out nIndex      : number optional ) : boolean;

Return value

  • true if the data source expects data

  • false otherwise

Parameter Description
cCursor Cursor associated with a database connection.
sIdentifier Variable receiving the identifier of the place holder or result data column whose item has to be sent to the data source (optional).
nIndex Variable receiving the array index of the place holder or column item that has to be sent to the data source (optional).

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 (?, ?);