OdbcGetStmtAttr Function

Action

Retrieves the current value of a specified SQL statement attribute.

Include file

ODBC.bdh

Syntax

OdbcGetStmtAttr( in  cCursor    : cursor,
                 in  nAttribute : number,
                 out nValue     : number): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
cCursor Cursor associated with a database connection.
nAttribute

SQL statement attribute whose value is to be retrieved. This parameter must be set to one of the following values:

  • SQL_ATTR_CONCURRENCY

  • SQL_ATTR_CURSOR_TYPE

  • SQL_ATTR_MAX_LENGTH

  • SQL_ATTR_MAX_ROWS

  • SQL_ATTR_NOSCAN

  • SQL_ATTR_QUERY_TIMEOUT

  • SQL_ATTR_RETRIEVE_DATA

  • SQL_ATTR_SIMULATE_CURSOR

  • SQL_ATTR_USE_BOOKMARKS

nValue Variable that will receive the value of the SQL statement attribute.

Example

var
  hEnv, hDbc : number;
  cCursor    : cursor;

dcltrans
  transaction TMain
  var
    nTimeout : number;
  begin
    OdbcAlloc(SQL_HANDLE_ENV, hEnv);
    OdbcAlloc(SQL_HANDLE_DBC, hDbc, hEnv);
    OdbcConnect(hDbc, "DSN=database;UID=user;PWD=pass;");
    OdbcOpen(cCursor, hDbc);
    OdbcSetStmtAttr(cCursor, SQL_ATTR_QUERY_TIMEOUT, 15);
    OdbcGetStmtAttr(cCursor, SQL_ATTR_QUERY_TIMEOUT, nTimeout );
    OdbcPrepare(cCursor, sqlSelect);
    OdbcExecute(cCursor);

    while OdbcFetch(cCursor) do
      write("name: " + OdbcGetString(cCursor, "1"));
      writeln(" age: " + (string)OdbcGetInt(cCursor, "2"));
    end;

    OdbcClose(cCursor, SQL_DROP);
    OdbcCommit(hDbc);
    OdbcDisconnect(hDbc);
    OdbcFree(hDbc);
    OdbcFree(hEnv);
  end TMain;

dclsql
  sqlSelect:
  SELECT * FROM persons;