How can I do an UPDATE OR CREATE ?

From: Guy Fraser <guy(at)incentre(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: How can I do an UPDATE OR CREATE ?
Date: 1999-07-21 17:08:26
Message-ID: 3795FE8A.BB24815F@incentre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I am trying to figure out how I can create an entry if one does not
exist when attempting an update.

This kind of what I want to do :

if (select "User-Name","Realm" from details;) {
update details set "Time-Used" = old."Time-Used" +
new."Time-Used";
} else {
insert into details "User-Name","Realm","Time-Used";
}

I have not seen any documentation specifying what pragmatic operators
are available if any.

Thank You In Advance

Guy Fraser
mailto:guy(at)incentre(dot)net

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 1999-07-21 17:20:09 Re: [SQL] bad select performance fixed by forbidding hash joins
Previous Message Guy Fraser 1999-07-21 16:48:40 How can I do an UPDATE OR CREATE ?