Updating an emty table? - Mailing list pgsql-general

From Bjorn T Johansen
Subject Updating an emty table?
Date
Msg-id 46175.193.212.14.12.1056530416.squirrel@www.havleik.no
Whole thread Raw
Responses Re: Updating an emty table?  (Hubert Lubaczewski <hubert.lubaczewski@eo.pl>)
Re: Updating an emty table?  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Hi..

I have a small "problem" and I was wondering if you guys could give me a
recommendation. I have a table that initially is empty but the table is
always updated, so there is no insert first then update..
The table can hold 10-20 records for each order, and I was wondering how
to implement this update. There are two alternatives as far as I can
see..:

1. I can delete every row for the order on every update and do an insert
instead.

2. or I can write a function (stored proc) that first tries to update
and if update fails, it then does an insert.

The first one I know how to do (don't know how much penalty this would
cause?) and the second one is perhaps the best way to do it, but since I
have never written any stored proc for PostgreSQL yet, I need some
pointers on how to implement this...


Regards,

BTJ


-----------------------------------------------------------------------------------------------
Bjørn T Johansen (BSc,MNIF)
Executive Manager
btj@havleik.no                  Havleik Consulting
Phone : +47 67 54 15 17         Conradisvei 4
Fax : +47 67 54 13 91           N-1338 Sandvika
Cellular : +47 926 93 298       http://www.havleik.no
-----------------------------------------------------------------------------------------------
"The stickers on the side of the box said "Supported Platforms: Windows
98, Windows NT 4.0,
Windows 2000 or better", so clearly Linux was a supported platform."
-----------------------------------------------------------------------------------------------


pgsql-general by date:

Previous
From: "Ivar"
Date:
Subject: Re: bytea char escaping
Next
From: Jean-Christophe ARNU (JX)
Date:
Subject: pg_statistic_relid_att_index