X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A0E2AD1B18A for ; Thu, 15 Jul 2004 14:49:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80488-06 for ; Thu, 15 Jul 2004 17:49:27 +0000 (GMT) Received: from relay.snowman.net (snowman.net [66.93.83.236]) by svr1.postgresql.org (Postfix) with ESMTP id BCA38D1B233 for ; Thu, 15 Jul 2004 14:49:22 -0300 (ADT) Received: from ns.snowman.net (ns.snowman.net [10.10.0.2]) by relay.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id i6FHnIJ5011426; Thu, 15 Jul 2004 13:49:18 -0400 Received: from ns.snowman.net (localhost [127.0.0.1]) by ns.snowman.net (8.12.11/8.12.11/Debian-5) with ESMTP id i6FHnWcQ011690; Thu, 15 Jul 2004 13:49:32 -0400 Received: (from sfrost@localhost) by ns.snowman.net (8.12.11/8.12.11/Debian-5) id i6FHnW6U011688; Thu, 15 Jul 2004 13:49:32 -0400 Date: Thu, 15 Jul 2004 13:49:32 -0400 From: Stephen Frost To: Jeff Kowalczyk Cc: pgsql-sql@postgresql.org Subject: Re: 'UPDATE OR INSERT' command Message-ID: <20040715174932.GS21419@ns.snowman.net> Mail-Followup-To: Jeff Kowalczyk , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cw81t83UHTonwpSu" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/2.4.24ns.3.0 (i686) X-Uptime: 13:48:46 up 166 days, 12:52, 15 users, load average: 0.06, 0.11, 0.09 User-Agent: Mutt/1.5.5.1+cvs20040105i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/96 X-Sequence-Number: 18348 --cw81t83UHTonwpSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Jeff Kowalczyk (jtk@yahoo.com) wrote: > Is there a postgresql SQL idiom to perform an UPDATE, which becomes an > INSERT if the primary key does not exist? >=20 > I'm not sure I *should* use it in my application, I just want to know if > it can be done. Thanks. Unfortunately, I don't believe there's one in PostgreSQL yet. MERGE is similar to this, and is defined in the latest SQL spec. Hopefully it'll be implemented in PostgreSQL sometime soon. Stephen --cw81t83UHTonwpSu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFA9sOrrzgMPqB3kigRAq6sAJ0fF1pN4TbFPcpnwJ9WrXROjDTh+wCgjO9x dunf06OtCwOPnLNIbeo5O0E= =gtk5 -----END PGP SIGNATURE----- --cw81t83UHTonwpSu--