Error code handling in perl

Поиск
Список
Период
Сортировка
От Elinor Medezinski
Тема Error code handling in perl
Дата
Msg-id 200405161456.10022.elinor@bellatrix.tau.ac.il
обсуждение исходный текст
Ответы Re: Error code handling in perl
Список pgsql-interfaces
Hi all,

I am populating a table in postgres, writing the script in perl (using DBI),
and I am trying to do some error handling.  For example - this should return
an error due to unique violation:
>$sth=$conn->prepare("INSERT INTO tablename (names) values ($name)") or die
"error1 is: ".$sth->err;

>$sth->execute() or do{
>  print "state is: ".$sth->state."\n";
>  print "err is: ".$sth->err."\n";
>};

I always get the same SQLSTATE and ERROR, no matter what the error is:

>state is: S1000
>err is: 7

although in the documentation it says that the error code is "23505" (unique
violation).
Is there no way to identify the error by code from postgres via perl?

Thanks,
Elinor

-------------------------------------------------------



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Bug in translation of DEALLOCATE PREPARE
Следующее
От: Michael Meskes
Дата:
Сообщение: Re: Bug in translation of DEALLOCATE PREPARE