Re: Update on Insert

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: SebiF <sfeher(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Update on Insert
Date: 2009-11-16 19:10:10
Message-ID: 603c8f070911161110i58c12459jeced1b1c10e3af7a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Mon, Nov 16, 2009 at 1:31 PM, SebiF <sfeher(at)gmail(dot)com> wrote:
> Hi Everyone,
>
> Given a table "Items" with a PK "item1" and "Qty" - a numeric column
> I'd like to define a way in Postgres to insert when item11 doesn't
> exist already in "Items" and update the Qty by adding the new quantity
> to the existent when the item11 exists. What is a good approach and
> where should I be looking for details. Thanks.
>
> Sebastian

This is not a -hackers question; please use pgsql-general instead.

Also see example 38-2 here:
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html

...Robert

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond Rodgers 2009-11-16 19:12:50 Re: Need full search text on a shared hosting web site using 8.1.x
Previous Message Tom Lane 2009-11-16 18:51:08 Re: Need full search text on a shared hosting web site using 8.1.x

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2009-11-16 19:10:23 Re: ORDER BY vs. volatile functions
Previous Message Robert Haas 2009-11-16 19:07:26 Re: Unpredictable shark slowdown after migrating to 8.4