Q: insert/update in same statement

From: grk(at)usa(dot)net (G(dot) Ralph Kuntz, MD)
To: pgsql-sql(at)postgresql(dot)org
Subject: Q: insert/update in same statement
Date: 2003-09-12 17:55:17
Message-ID: 9881c752.0309120955.72b8460e@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message G. Ralph Kuntz, MD 2003-09-12 17:58:45 Q: select query
Previous Message Richard Huxton 2003-09-12 16:18:39 Re: createlang plpgsql failing on redhatlinux7.2