pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Elinor Medezinski <elinor@bellatrix.tau.ac.il>
To: pgsql-interfaces@postgresql.org
Cc: elinor@wise.tau.ac.il
Subject: Error code handling in perl
Date: Sun, 16 May 2004 14:56:10 +0300
Message-ID: <200405161456.10022.elinor@bellatrix.tau.ac.il> (raw)


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

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




view thread (2+ messages)  latest in thread

Message-ID: <200405161456.10022.elinor@bellatrix.tau.ac.il>
Permalink:  ../200405161456.10022.elinor@bellatrix.tau.ac.il/
Also on:    postgresql.org/message-id/200405161456.10022.elinor@bellatrix.tau.ac.il

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: elinor@bellatrix.tau.ac.il, elinor@wise.tau.ac.il
  Subject: Re: Error code handling in perl
  In-Reply-To: <200405161456.10022.elinor@bellatrix.tau.ac.il>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox