Pascal Data Objects

function TPDO.errorInfo: PDO_errorInfoRecord;

TPDO.errorInfo returns an record of error information about the last operation performed by this database handle. The record is defined as follows:

  PDO_errorInfoRecord = record
        SQLState:    AnsiString;   {SQLSTATE error code (a five-character identifier defined in the ANSI SQL standard)}
        Error_code:  Integer;      {Driver-specific error code}
        Error_msg:   AnsiString;   {Driver-specific error message}

TPDO.errorInfo only retrieves error information for operations performed directly on the database handle. If you create a IPDOStatement object through TPDO.prepare_select, TPDO.prepare_as_is, TPDO.query_as_is or TPDO.query_select and invoke an error on the statement handle, TPDO.errorInfo will not reflect the error from the statement handle. You must call IPDOStatement.errorInfo to return the error information for an operation performed on a particular statement handle.

  db.execute_now ('INSERT INTO bones(skull) VALUES (''lucy'')');
  writeln ('TPDO.errorInfo(): ');
  writeln ('SQLState:   ' + db.errorInfo.SQLState);
  writeln ('Error Code: ' + db.errorInfo.Error_code);
  writeln ('Error Msg:  ' + db.errorInfo.Error_msg);

The above example will output:

SQLState:   42S02
Error Code: -204
Error Msg:  [IBM][CLI Driver][DB2/LINUX] SQL0204N  "DANIELS.BONES" is an undefined name.  SQLSTATE=42704