Page 1 of 1

trouble getting postgresql error message

Posted: Sun 27 Feb 2011 15:37
by dschuch
Hy, i have some trouble getting the correct error message from the postgres server to the client. it seems like a pgdac problem.

serverside the error is raised like that:

ERROR: update or delete on table "art" violates foreign key constraint "artoption_arts_aph_ak_nr_fkey" on table "artoption_arts"
SQL Status:23503
Detail:Key (ak_nr)=(TEST) is still referenced from table "artoption_arts".

(also shown in psql)

@ the client, only the first part of the error message is visble. (the content after ERROR:)
The SQL Status is missing as well as the important DETAIL part.

what to do, to get the important detail part through PGDAC to the user. I'm sure, in earlier versions that worked well. (much earlier, think the problem is about a half year, but i thought the reason was that we upgraded from postgres 81 to 90, but that isnt the reason, the error from the server is correct).


PS:

i checked that with ado too, here the error message looks like that:

update or delete on table "art" violates foreign key constraint "artoption_arts_aph_ak_nr_fkey" on table "artoption_arts"
Key (ak_nr)=(TEST) is still referenced from table "artoption_arts".

... so the user can see the ERROR and DETAIL part. SQL Status is hidden, like in PGDAC too, thats ok.

Posted: Sun 27 Feb 2011 17:17
by dschuch
xxx

Posted: Sun 27 Feb 2011 17:19
by dschuch
i was a bit confused now - with a UPDATE and ForeignKey violations the current error message seems ok. Both tables are in the error message, so the user can read the message (both tables are there >Update on table >>articles>customers<<) without the DETAILS part.

but with insert violations the second tablename isnt clear:

LOLL1=# INSERT INTO art (ak_ac, ak_nr) VALUES ('XXAS', 'XYZ');
ERROR: insert or update on table "art" violates foreign key constraint "art_ak_ac_fkey"
DETAIL: Key (ak_ac)=(XXAS) is not present in table "artcod".

the user cant know the backgrounds of foreign key "art_ak_ac_fkey" so he doesnt know that the problem is the 2nd table "artcod". The DETAILS part of the error message is realy important for the user here.

Posted: Mon 28 Feb 2011 08:42
by AlexP
To resolve the problem you can use the EPgError class like:

Code: Select all

uses PgError;

....

  try
    PgQuery.Delete;
  except
    on E: EPgError do
    begin
      ShowMEssage('Message: ' + e.Message+ ';' + #13 + 'SQL Status: ' + e.ErrorCode + #13+ 'Detail: ' + e.DetailMsg);
    end;

end;

Posted: Mon 28 Feb 2011 09:44
by dschuch
working, thx

Posted: Mon 28 Feb 2011 09:51
by AlexP
Hello,

It is good to see that this problem was solved. If any other questions come up, please contact us.