pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Roland Roberts <roland@astrofoto.org>
To: pgsql-sql@postgresql.org
Subject: Re: PL/pgSQL examples NOT involving functions
Date: Thu, 15 Nov 2001 16:19:23 -0800
Message-ID: <web-507249@davinci.ethosmedia.com> (raw)
In-Reply-To: <m2snbfg276.fsf@tycho.rlent.pnet>

Roland,

> Hmm, there were some complaints recently on the hackers list about
> things being posted on only one list.  And a significant chunk of the
> mail I am getting from lists shows it was posted to more than one
> list.

Yeah, and you'll notice me saying "please don't cross-post" a lot.
Basically I'm trying to encourage people to NOT  cross-post because we
end up with a lot of questions being answered 2 and 3 times on different
lists.  It's really not fair to the people who are trying to be helpful
and answer questions.  Hackers is one of the lists I am not subscribed
to (I currently read SQL, NOVICE, PHP and ANNOUNCE).

> So how would I convert an insert to an update when I detect a tuple
> is
> already present in the database?  Do I have to write the whole thing
> in Perl/Tcl/whatever and do the conversion there?

Yes.  Use the EXECUTE method.  Or do it in your middleware.  Or
establish a unique index, do both an insert and an update, and ignore
the error messages.

Or ... if you wanna get really tricky ... write some triggers to do the
substitution.  

Personally, I find that keeping track, on the client side, of whether
you're adding a new record or editing an old one and acting
appropriately is better than trying to second-guess it on the database
level, but maybe that's just me.

-Josh


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



view thread (21+ messages)  latest in thread

Message-ID: <web-507249@davinci.ethosmedia.com>
Permalink:  ../web-507249@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-507249@davinci.ethosmedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: josh@agliodbs.com, roland@astrofoto.org, pgsql-sql@postgresql.org
  Subject: Re: PL/pgSQL examples NOT involving functions
  In-Reply-To: <web-507249@davinci.ethosmedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox