Page 1 of 1

EZDatabaseError error codes.

Posted: 08.09.2015, 16:02
by jjeffman
Hello,

I would like to use the EZDatabaseError::ErrorCode property to implement different application messages according to the returned value of it. May I presume that the ErrorCode property assumes the value raised by database client software ?

Is there any list of values which can be used as a reference for ErrorCode ?

The code below I have copied from the file ZAbstractRODataset.pas :

Code: Select all

  
  {** Implements a Zeos specific database exception with SQL error code. }
  EZDatabaseError = class(EDatabaseError)
  private
    FErrorCode: Integer;
    FStatusCode: String;
    procedure SetStatusCode(const Value: String);
   public
    constructor Create(const Msg: string);
    constructor CreateFromException(E: EZSQLThrowable);

    property ErrorCode: Integer read FErrorCode write FErrorCode;
    property StatusCode: String read FStatusCode write SetStatusCode;
  end;
The class EDatabaseError from which EZDatabaseError derives has no the ErrorCode property.

Thank you very much.

Re: EZDatabaseError error codes.

Posted: 08.09.2015, 19:15
by marsupilami
Hello Jayme,

I think that depends very much on the DBC database driver that is in use. Maybe you should have a look at the source on how the driver that you use works.
With best regards,

Jan

Re: EZDatabaseError error codes.

Posted: 08.09.2015, 19:35
by jjeffman
Thank you marsupilami,
marsupilami wrote:Hello Jayme,

I think that depends very much on the DBC database driver that is in use. Maybe you should have a look at the source on how the driver that you use works.
With best regards,

Jan
I am using a mysql database and the "mysql" protocol, so what is the ErrorCode for "Parent key not found" or "Duplicate entry" ?

Thank you very much.

Kind regards

Re: EZDatabaseError error codes.

Posted: 16.09.2015, 16:06
by marsupilami
Hello Jayme,

honestly, I don't know the error codes. I can only suggest to you again to have a look into the source code of the MySQL DBC layer driver.
With best regards,

Jan

Re: EZDatabaseError error codes.

Posted: 16.09.2015, 18:03
by jjeffman
Hello Marsupilami,

Unfortunately the ErrorCode which is being attached during the Exception creation has nothing to do with the mysql error, so in fact I would need a list of EZDatabaseError ErrorCode values and meaning to take decisions inside the try-catch block.

As I am interested only in some of them I have provoked the database errors and saved some EZDatabaseError error codes. So this thread can be marked as solved.

Best regards.