OdbcSetCursorName Function

Action

Assigns a user-defined name to a cursor. Usually, Silk Performer generates and uses an internally generated cursor name whenever a SQL query statement is either prepared or executed directly. This function enables you to replace this internally generated cursor name with a user-defined name. This user-defined cursor name can then be used in place of the internally generated cursor name in positioned UPDATE and positioned DELETE statements.

Include file

ODBC.bdh

Syntax

OdbcSetCursorName( in cCursor : cursor,
                   in sName   : string ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
cCursor Cursor associated with a database connection.
sName User-defined cursor name that Silk Performer uses instead of the internally generated name.

Example

var
  hEnv, hDbc : number;
  c1, c2     : cursor;

dcltrans
  transaction TMain
  begin
    OdbcAlloc(SQL_HANDLE_ENV, hEnv);
    OdbcAlloc(SQL_HANDLE_DBC, hDbc,mhEnv);
    OdbcConnect(hDbc, "DSN=database;UID=user;PWD=pass;");
    OdbcOpen(c1, hDbc);
    OdbcPrepare(c1, sqlSelect);
    OdbcSetCursorName(c1, "cursor_persons");
    OdbcExecute(c1);
    OdbcFetch(c1);
    OdbcOpen(c2, hDbc);
    OdbcPrepare(c2, sqlDelete);
    OdbcExecute(c2);
    OdbcClose(c1, SQL_DROP);
    OdbcClose(c2, SQL_DROP);
    OdbcCommit(hDbc);
    OdbcDisconnect(hDbc);
    OdbcFree(hDbc);
    OdbcFree(hEnv);
  end TMain;

dclsql
  sqlSelect:
    SELECT * FROM persons;
  sqlDelete:
    DELETE FROM persons WHERE CURRENT OF cursor_persons;