Skip site navigation (1) Skip section navigation (2)

Re: how to overwrite tuples in a table

From: "Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
To: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>,"Pradeepkumar, Pyatalo (IE10)" <Pradeepkumar(dot)Pyatalo(at)honeywell(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to overwrite tuples in a table
Date: 2004-09-10 04:31:13
Message-ID: 77ED2BF75D59D1439F90412CC5B10974116D31C5@ie10-sahara.hiso.honeywell.com (view raw or flat)
Thread:
Lists: pgsql-novice
No I am not looking for UPDATE command.For updating first i should check if
there is a tuple with the given pointid and attributeid, if present then i
should use the UPDATE command.....thats fine. But what I wanted was a
situation wherein, I will blindly call the insert command and the database
takes care of overwriting the previous values.....is that possible.


-----Original Message-----
From: Sean Davis [mailto:sdavis2(at)mail(dot)nih(dot)gov]
Sent: Thursday, September 09, 2004 7:55 PM
To: Pradeepkumar, Pyatalo (IE10)
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] how to overwrite tuples in a table


Are you looking for UPDATE?

http://www.postgresql.org/docs/7.4/static/sql-update.html

Sean

UPDATE pointattributes SET strvalue='Good Morning', numvalue=9 WHERE 
pointid=7 AND attributeid=50;

On Sep 9, 2004, at 10:13 AM, Pradeepkumar, Pyatalo (IE10) wrote:

> Hi,
>  
> I have a table 
> pointattributes(pointid,attributeid,strvalue,numvalue)......where 
> pointid and attributeid are foreign keys refering to other tables. Now 
> how can i overwrite tuples in this table. To make it simpler,
> pointid        attributeid        strvalue        numvalue
> ----------------------------------------------------------------------
> 4                    45                    hello                3
> 7                    50                    hai                   9
>  
> I want this table to retain the latest data.....
> so if i say insert into pointattributes values(7,50,'Good 
> Morning',10), it should overwrite the previous tuple with this latest 
> one. Is there a way to do that.
> One simple way is to check if there are any tuples with the given 
> pointid and attributeid, if a tuple exists delete the tuple with the 
> pointid and attribute(the combination is unique) and then insert the 
> new tuple.
> But is there any better way to do that.
>  
> Thanks in advance.
>  
>
> With Best Regards
> Pradeep Kumar P J
>

Responses

pgsql-novice by date

Next:From: Jake StrideDate: 2004-09-10 06:36:17
Subject: Copying
Previous:From: the inquirerDate: 2004-09-09 17:49:26
Subject: PL/pgSQL Function Problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group