pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: grk@usa.net
To: pgsql-sql@postgresql.org
Subject: Q: insert/update in same statement
Date: 12 Sep 2003 10:55:17 -0700
Message-ID: <9881c752.0309120955.72b8460e@posting.google.com> (raw)

Is it possible to make a single SQL statement that will insert a row
if it does not already exist, otherwise it will just update the
fields?

Actually, just a statement that will not give an error about duplicate
keys would be enough for my application.

Something like

INSERT INTO SOME_TABLE (FIELD1, ...) VALUES (VALUE1, ...) WHERE
KEY_FIELD DOES NOT EXIST;

I am working in PostgreSQL 7.3.x.

Thanks, Ralph



view thread (2+ messages)  latest in thread

Message-ID: <9881c752.0309120955.72b8460e@posting.google.com>
Permalink:  ../9881c752.0309120955.72b8460e@posting.google.com/
Also on:    postgresql.org/message-id/9881c752.0309120955.72b8460e@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: grk@usa.net
  Subject: Re: Q: insert/update in same statement
  In-Reply-To: <9881c752.0309120955.72b8460e@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox