From: | "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, gentosaker(at)gmail(dot)com |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Ignore unique violations? |
Date: | 2008-03-27 12:50:59 |
Message-ID: | 396486430803270550h6f0804b9x6933d6bb3b0a1b4e@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Thu, Mar 27, 2008 at 2:52 AM, A. Kretschmer
<andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> am Thu, dem 27.03.2008, um 9:45:33 +0000 mailte A B folgendes:
>
> > Is there any easy way of ignoring unique violations?
> > I have a table (a integer, b integer, unique (a,b) ) and want to
> > insert pairs of values for a and b, but I do not want to first select
> > to see if there is a pair before inserting.
> > So can I make postgres ignore any error or exception?
>
> I hope this link can help you:
> http://andreas.scherbaum.la/blog/archives/11-Avoid-Unique-Key-violation.html
>
>
Here is different syntax for the same solution.
INSERT INTO Table ( a, b )
SELECT T1.a, T1.b
FROM ( VALUES( 1, 2 )) AS T1( a, b )
LEFT OUTER JOIN Table AS T2
ON ( T1.a, T1.b ) = ( T2.a, T2.b )
WHERE ( T2.a, T2.b ) IN NULL;
--
Regards,
Richard Broersma Jr.
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Marcher | 2008-03-27 18:13:29 | Documentation Tool |
Previous Message | ashish | 2008-03-27 11:39:59 | Re: Restoring DB using Continuous Archive Backup |