dbTalk Databases Forums  

Update on Insert

comp.databases.postgresql comp.databases.postgresql


Discuss Update on Insert in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SebiF
 
Posts: n/a

Default Update on Insert - 11-16-2009 , 12:31 PM






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

Reply With Quote
  #2  
Old   
Andreas Kretschmer
 
Posts: n/a

Default Re: Update on Insert - 11-16-2009 , 02:53 PM






SebiF <sfeher (AT) gmail (DOT) com> wrote:
Quote:
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.
21:53 < akretschmer> ??upsert
21:53 < rtfm_please> For information about upsert
21:53 < rtfm_please> see http://www.postgresql.org/docs/curre...UPSERT-EXAMPLE

Read that.


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.