OdbcSetStmtAttr Function

Action

Modifies the current value of a specified SQL statement attribute.

Include file

ODBC.bdh

Syntax

OdbcSetStmtAttr(
   in cCursor    : cursor,
   in nAttribute : number,
   in sValue     : string ) : 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 modified. 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

sValue New value for the SQL statement attribute.

Example

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);
    OdbcSetStmtAttr(cCursor, SQL_ATTR_QUERY_TIMEOUT, 15);
    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;