Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 426251337BA5 for ; Tue, 30 Nov 2010 10:16:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 11296-06-4 for ; Tue, 30 Nov 2010 14:16:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx01.bfk.de (mx01.bfk.de [193.227.124.2]) by mail.postgresql.org (Postfix) with ESMTP id 19DC01337B90 for ; Tue, 30 Nov 2010 10:16:23 -0400 (AST) Received: from mx00.int.bfk.de ([10.119.110.2]) by mx01.bfk.de with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1PNR0J-0001xg-GQ; Tue, 30 Nov 2010 14:16:23 +0000 Received: by bfk.de with local id 1PNR0J-0001dm-DI; Tue, 30 Nov 2010 14:16:23 +0000 To: Cc: Subject: Re: Is there a solution for "SELECT OR INSERT" References: <000001cb8f54$4a9e3c20$dfdab460$@de> From: Florian Weimer Date: Tue, 30 Nov 2010 14:16:23 +0000 In-Reply-To: <000001cb8f54$4a9e3c20$dfdab460$@de> (Stefan Becker's message of "Mon\, 29 Nov 2010 00\:30\:47 +0100") Message-ID: <82aakq99s8.fsf@mid.bfk.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/89 X-Sequence-Number: 34827 * Stefan Becker: > Is there a way to get the ID row OR create a new one in > ONE single statement? You could create a stored procedure. But if you have concurrent inserts, locking is a bit tricky. --=20 Florian Weimer BFK edv-consulting GmbH http://www.bfk.de/ Kriegsstra=DFe 100 tel: +49-721-96201-1 D-76133 Karlsruhe fax: +49-721-96201-99