OraLastErrorText Function

Action

Retrieves the error message describing the last error that occurred. The error code can be retrieved using the OraOciError function and the OraApiError function.

Include file

Ora.bdh

Syntax

OraLastErrorText(): string;

Return value

error message

Example

var
  hConnection : number;
  cCursor : cursor;

dcltrans
  transaction TMain
  begin
    OraLogon(hConnection, "user", "password", "orclnet2");
    OraOpen(cCursor, hConnection);
    OraParse(cCursor, sqlDelete);

    // Oracle error 900: invalid SQL statement
    OraIgnoreError(cCursor, 900);

    // execute invalid SQL statement
    OraExec(cCursor);
     write(OraLastErrorText());
    
    OraClose(cCursor);
    OraLogoff(hConnection);
  end TMain;

dclsql
  sqlDelete:
    REMOVE FROM my_table; 
    // invalid SQL statement

Output

OCI-API Class 0 Error (Warning) 900 in OraExec(OEXEC, OEXN):
ORA-00900: invalid SQL statement