Обсуждение: How to get last Error Message/Code

Поиск
Список
Период
Сортировка

How to get last Error Message/Code

От
Earth Analizer
Дата:
Hi,

I am new to Postgres and I would like to know how I can get the last error message.
I am using a programming language called "Paradox" and, when an error occurs,
it converts the Postgres error code to its own error code.
Sometimes Paradox displays a funny message, if it does not recognize the code and
the error message it displays gives me no clue for what actually happened.

if anyone knows the solution, please let me know.

Thank you in advance.
Cheers!

Re: How to get last Error Message/Code

От
John R Pierce
Дата:
On 08/03/11 10:03 PM, Earth Analizer wrote:
> Hi,
>
> I am new to Postgres and I would like to know how I can get the last
> error message.
> I am using a programming language called "Paradox" and, when an error
> occurs,
> it converts the Postgres error code to its own error code.
> Sometimes Paradox displays a funny message, if it does not recognize
> the code and
> the error message it displays gives me no clue for what actually happened.
>
> if anyone knows the solution, please let me know.
>
> Thank you in advance.
> Cheers!

any SQL errors should be in postgres' logfile, which typically is
accessible only to the postgres user, in the pg data/pg_log directory

I usually like to make a few tweaks to the logging defaults, like


     log_line_prefix = '%m %u@%d[%p]:'

which will timestamp the logs, and give you user@database[pid]: in front
of each entry, like...

2011-08-04 02:06:46.681 PDT postgres@postgres[12927]:ERROR:  column
"junk" does not exist at character 8
2011-08-04 02:06:46.681 PDT postgres@postgres[12927]:STATEMENT:  select
junk;


--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast