Error Trapping -duplicate keys

From: "Steven D(dot) Smith" <sds07(at)health(dot)state(dot)ny(dot)us>
To: pgsql-novice(at)postgresql(dot)org
Subject: Error Trapping -duplicate keys
Date: 2002-07-02 11:40:37
Message-ID: OF2AFA5B96.70E5AF0C-ON85256BEA.003EF531@health.state.ny.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Help:

I'm using Perl to insert data from a log file, what I am doing is this
(Pseudocode):

If NOT (INSERT INTO myTABLE)
THEN UPDATE myTABLE
endIf

Now the code I have works except I get a console message:

DBD::Pg::st execute failed: ERROR: Cannot insert a duplicate key
into unique index visitor_pkey at ./inslog.pl line 147, <> chunk 4.

So, my question is how to I trap this error, keep it from being display as
it is not really an error if the insert fails?

Many thanks!

S. Douglas Smith Sr.
-------------------------------------------------------------------------------------------------

"Simplicity is the most difficult thing to secure in this world; it is the
last limit of experience, and the last effort of genius." George Sand

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Ludwig Lim 2002-07-02 12:00:21 Re: Error Trapping -duplicate keys
Previous Message Pierre-Yves LANDURE 2002-07-02 07:40:11 Agregation Function