EDAError not always showing correct error code

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
adroege
Posts: 16
Joined: Tue 07 Apr 2009 16:13
Location: Orlando, FL

EDAError not always showing correct error code

Post by adroege » Wed 24 Feb 2010 21:57

I am using Delphi 7, UniDAC 2.7.0.8, PostgreSQL 8.3.7

EDAError(E).ErrorCode not reporting the error code.

For example:

var
aQuery: TUniQuery;
begin
aQuery:= TUniQuery.Create( nil );
aQuery.sql.add( 'select log(-1)' );
try
aQuery.Execute;
except
on E: EDAError do
ShowMessage( IntToStr( E.ErrorCode ) + ' ' + E.Message );
end;
end;

E.ErrorCode = 0, it should be 2201E according to the PostgreSQL Error Code table
http://www.postgresql.org/docs/8.3/inte ... endix.html

E.ErrorMessage = cannot take logarithm of a negative number

Thank you
Alan

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Fri 26 Feb 2010 13:35

This is because PostgreSql unlike other Database servers has string error code. Try the following code:

Code: Select all

ShowMessage (EPgError(EUniError(E).InnerError).ErrorCode);

adroege
Posts: 16
Joined: Tue 07 Apr 2009 16:13
Location: Orlando, FL

Post by adroege » Fri 26 Feb 2010 14:10

It works!

Thank you very much.

Alan

Post Reply