Re: plpgsql function to insert or update problem - Mailing list pgsql-general

From Alban Hertroys
Subject Re: plpgsql function to insert or update problem
Date
Msg-id B04995AC-072D-4D43-B441-3F5C6189BF3D@gmail.com
Whole thread Raw
In response to plpgsql function to insert or update problem  (Andy Colson <andy@squeakycode.net>)
Responses Re: plpgsql function to insert or update problem  (Andy Colson <andy@squeakycode.net>)
List pgsql-general
On 23 Mar 2012, at 19:49, Andy Colson wrote:

> Anyway, the problem.  I get a lot of DB Error messages:
> DB Error: ERROR:  duplicate key value violates unique constraint "by_ip_pk"
> DETAIL:  Key (ip, sessid, "time")=(97.64.237.59, 2qggi9gcdkcaoecqg3arvo1gu7, 2012-03-23 13:00:00) already exists.
> CONTEXT:  SQL statement "insert into by_ip(vhost, time, ip, sessid, hits)
>                        values (vid, date_trunc('hour', ihittime), iip, isessid, 1)"

> Why is it hitting the insert statement?  Why doesn't the "if not found" seem to work?  Any hints would be
appreciated.


You forgot about vid in your PK ;)

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.


pgsql-general by date:

Previous
From: Thom Brown
Date:
Subject: Re: broken xlog - recovery plan check
Next
From: Bruce Momjian
Date:
Subject: Re: pgcon 2012