OdbcSetPos Function

Action

Sets the cursor position in a row set, refreshes data in a row set, or adds, updates and/or deletes data in an updatable result data set.

Include file

ODBC.bdh

Syntax

OdbcSetPos(
   in cCursor    : cursor,
   in nRow       : number,
   in nOperation : number,
   in nLockType  : number): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
cCursor Cursor associated with a database connection.
nRow Ordinal position of the row in the row set on which to perform the operation specified in the nOperation parameter. If this parameter is set to 0, the operation specified is performed on every row in the row set.
nOperation

Operation to perform. This parameter must be set to one of the following values:

  • SQL_POSITION

  • SQL_REFRESH

  • SQL_UPDATE

  • SQL_DELETE

  • SQL_ADD

nLockType

Specifies how to lock the row after performing the operation specified in the nOperation parameter. This parameter must be set to one of the following values:

  • SQL_LOCK_NO_CHANGE

  • SQL_LOCK_EXCLUSIVE

  • SQL_LOCK_UNLOCK

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);
    OdbcPrepare(cCursor, sqlSelect);
    OdbcExecute(cCursor);
    OdbcDefine(cCursor, "1", SQL_C_CHAR, 32);
    OdbcDefine(cCursor, "2", SQL_C_LONG);
    OdbcFetch(cCursor, 20);
    OdbcSetPos(cCursor, 5, SQL_POSITION, SQL_LOCK_NO_CHANGE);
    write("name: " + OdbcGetString(cCursor, "1"));
    writeln(" age: " + (string)OdbcGetInt(cCursor, "2"));
    OdbcClose(cCursor, SQL_DROP);
    OdbcCommit(hDbc);
    OdbcDisconnect(hDbc);
    OdbcFree(hDbc);
    OdbcFree(hEnv);
  end TMain;

dclsql
  sqlSelect:
  SELECT * FROM persons;