Re: if exists...does it exists for insert statments?

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Pau Marc Munoz Torres <paumarc(at)gmail(dot)com>
Cc: PgSQL General ML <pgsql-general(at)postgresql(dot)org>
Subject: Re: if exists...does it exists for insert statments?
Date: 2007-12-11 22:10:16
Message-ID: 767744.63134.qm@web31811.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- On Tue, 12/11/07, Pau Marc Munoz Torres <paumarc(at)gmail(dot)com> wrote:

> Thanks, i'll test it tomorrow

OOPS, I just noticed a mistake.

INSERT INTO SP
SELECT a, b
FROM ( VALUES ( 'cesp', 'sp' )) AS tmp( a, b )
LEFT JOIN Sp
ON (Sp.col1,Sp.col2)=(tmp.a,tmp.b)
WHERE (Sp.col1,Sp.col2) IS NULL;

I forgot the parentheses that the FROM clause requires when using the VALUES predicate. Also remember that this only works in PostgreSQL versions >= 8.2.

Regards,
Richard Broersma Jr.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Howard Cole 2007-12-11 22:20:36 Re: Killing a session in windows
Previous Message Pau Marc Munoz Torres 2007-12-11 21:28:50 Re: if exists...does it exists for insert statments?