OraCancel Function

Action

Cancels a query after a number of rows have been fetched. This function releases any resources associated with the cursor except the internal representation of the parsed SQL statement.

Include file

Ora.bdh

Syntax

OraCancel(in cCursor: cursor): boolean;

Return value

  • true if successful

  • false otherwise. In this case, you can use the OraOciError function to retrieve the Oracle OCI error code

Parameter Description
cCursor Cursor associated with a database connection.

Example

var
  hConnection : number;
  cCursor : cursor;

dcltrans
  transaction TMain
  var
    sName : string;
    nAge : number;
  begin
    OraLogon(hConnection, "user", "password", "orclnet2");
    OraOpen(cCursor, hConnection);
    OraParse(cCursor, sqlSelect);
    OraExec(cCursor);
    OraDefine(cCursor, 1, SQLT_CHR, 32);
    OraDefine(cCursor, 2, SQLT_INT);
    // fetch first row
    OraFetch(cCursor);
    sName := OraGetString(cCursor, "1");
    nAge := OraGetInt(cCursor, "2");
    write(sName, 32); write(nAge, 3); writeln;
    OraCancel(cCursor);
    // Ignore Oracle error 1002: fetch out of sequence
    OraIgnoreError(cCursor, 1002);
    // try to fetch second row
    OraFetch(cCursor);
    OraClose(cCursor);
    OraLogoff(hConnection);
  end TMain;

dclsql
  sqlSelect:
    SELECT * FROM persons;

Output

Howard 33
OCI-API Class 0 Error (Warning) 1002 in OraFetch(OFETCH, OFEN):
ORA-01002: fetch out of sequence

See Also

Oracle's Programmer's Guide to Oracle Call Interface for the Wrapped Oracle function: ocan