Re: How to get last Error Message/Code

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get last Error Message/Code
Date: 2011-08-04 06:55:05
Message-ID: 4E3A4249.4090202@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)%d[%p]:'

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

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

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adarsh Sharma 2011-08-04 10:26:33 Re: Server Not Running
Previous Message Adarsh Sharma 2011-08-04 05:46:12 Server Not Running