Skip site navigation (1) Skip section navigation (2)

Error code handling in perl

From: Elinor Medezinski <elinor(at)bellatrix(dot)tau(dot)ac(dot)il>
To: pgsql-interfaces(at)postgresql(dot)org
Cc: elinor(at)wise(dot)tau(dot)ac(dot)il
Subject: Error code handling in perl
Date: 2004-05-16 11:56:10
Message-ID: 200405161456.10022.elinor@bellatrix.tau.ac.il (view raw or flat)
Thread:
Lists: 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

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


Responses

pgsql-interfaces by date

Next:From: Bruce MomjianDate: 2004-05-20 00:33:22
Subject: Re: Bug in translation of DEALLOCATE PREPARE
Previous:From: Stergios ZissakisDate: 2004-05-12 08:56:41
Subject: ECPG scoping

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group