X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5CDC8D1EC4B for ; Tue, 23 Mar 2004 16:54:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 56474-10 for ; Tue, 23 Mar 2004 12:54:53 -0400 (AST) Received: from bml.uk.com (unknown [195.60.21.19]) by svr1.postgresql.org (Postfix) with ESMTP id 48275D1EC4A for ; Tue, 23 Mar 2004 12:54:50 -0400 (AST) Received: from D4R74F0J [129.1.2.162] by bml.uk.com [127.0.0.1] with SMTP (MDaemon.v2.8.5.0.R) for ; Tue, 23 Mar 2004 16:47:39 +0000 From: "Rob Anderson" To: Subject: Testing for existence of a record before insert Date: Tue, 23 Mar 2004 16:41:40 -0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_004E_01C410F5.B7AA74D0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-MDaemon-Deliver-To: pgsql-admin@postgresql.org X-Return-Path: ROBA@bml.uk.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_44, HTML_50_60, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200403/300 X-Sequence-Number: 12869 This is a multi-part message in MIME format. ------=_NextPart_000_004E_01C410F5.B7AA74D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit I am trying to find a way of performing something similar to the SQL-Server SQL of IF NOT EXISTS (SELECT id FROM a_table WHERE id='akey') THEN INSERT INTO a_table (id, name) values ('akey', 'adetails'); --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.619 / Virus Database: 398 - Release Date: 10/03/2004 ------=_NextPart_000_004E_01C410F5.B7AA74D0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I am try= ing to find=20 a way of performing something similar to the SQL-Server SQL of=20
 
IF NOT E= XISTS=20 (SELECT id FROM a_table WHERE id=3D'akey')
THEN INS= ERT INTO=20 a_table (id, name) values ('akey', 'adetails');
 
 
------=_NextPart_000_004E_01C410F5.B7AA74D0--