Обсуждение: Error codes

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

Error codes

От
Francois Suter
Дата:
Hi all (again),

I have a database with quite a few UNIQUE constraints on foreign key pairs.
Logically when I try to insert a pair that already exists I get an error
from the PostgreSQL backend. I assume that such an error has an associated
error code and that such an error code is quite different from the one
generated, say, when a relationship is missing.

My question is then: is it possible to retrieve this error code, especially
in PHP, where it seems that the only function related to errors is
pg_errormessage() which only returns a string with no error code.

The thing is I would like to be able to differentiate between errors that
are expected (people trying to create a foreign key pair that already
exists) and which should just generate a warning and an error that happens
because someone stumbled on a bug (e.g. writing a null value to a NOT NULL
field).

Any hope of achieving that with PHP?

(I tried to look for error codes in the idocs and got either nothing or too
many hits, hence my previous mail :-)

--------
Francois

Home page: http://www.monpetitcoin.com/
"We waste our time spending money we don't have to buy things we don't need
to impress people we don't like"


Re: Error codes

От
Neil Conway
Дата:
On Thu, 2002-12-12 at 05:36, Francois Suter wrote:
> My question is then: is it possible to retrieve this error code, especially
> in PHP, where it seems that the only function related to errors is
> pg_errormessage() which only returns a string with no error code.

PostgreSQL does not currently support error codes. There is some talk of
implementing them for 7.4, but I don't think that's set in stone yet. In
the interim, perhaps you can grep the error string?

Cheers,

Neil