insert/update

From: Tom Allison <tallison(at)tacocat(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: insert/update
Date: 2004-05-26 10:54:05
Message-ID: 40B4774D.5040701@tacocat.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I seemed to remember being able to do this but I can't find the docs.

Can I run a sql query to insert new or update existing rows in one query?

Otherwise I have to run a select query to see if it's there and then
another one to update/insert.

What I'm trying to do is create a counter for each key, insert a value
of 1 or increment the value by 1 and then set another specific row
(where key = $key) to always increment by 1.

And the more I type, the more this sounds like the answer is going to be
part function, part trigger.... Maybe I should post to 'novice' for a
while! ;)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Thomas 2004-05-26 11:37:11 Re: insert/update
Previous Message Richard Huxton 2004-05-26 07:26:01 Re: About table schema