Page 1 of 1

EDAError not always showing correct error code

Posted: Wed 24 Feb 2010 21:57
by adroege
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

Posted: Fri 26 Feb 2010 13:35
by Challenger
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);

Posted: Fri 26 Feb 2010 14:10
by adroege
It works!

Thank you very much.

Alan