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

Insert with possible constraint violations?

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Insert with possible constraint violations?
Date: 2008-04-29 07:56:21
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
What is the proper way of inserting stuff into a table with two fields
(A and B) with a  constraint unique(A,B) and you suspect you will get
some unique constraint violations?
Should I just do INSERT etc...  and just ignore the answer?
Or do a select first and see if it returned any record?
Or is there a way of way to write a function that do the INSERT but
catches the error and do not write anything to the log about the
violation? In that case, what would such a function look like?
To me it seems that writing error messages  to log files  is not very
So what would you suggest me doing?


pgsql-novice by date

Next:From: Alan HodgsonDate: 2008-04-29 15:31:52
Subject: Re: Configuration on CentOS 4.6
Previous:From: Cedric BUSCHINIDate: 2008-04-29 07:26:59
Subject: - Advice about hardware configuration

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