Re: Bulk Insert / Update / Delete

From: Ian Harding <iharding(at)tpchd(dot)org>
To: Philip Boonzaaier <phil(at)cks(dot)co(dot)za>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Bulk Insert / Update / Delete
Date: 2003-08-19 08:09:17
Message-ID: 3F41DB2D.7070005@tpchd.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You are going to need a procedural language function. There are several
to choose from, they all support some kind of conditional loop. There
is plenty of documentation avaiable at postgresql.org.

Philip Boonzaaier wrote:

>I want to be able to generate SQL statements that will go through a list of
>data, effectively row by row, enquire on the database if this exists in the
>selected table- If it exists, then the colums must be UPDATED, if not, they
>must be INSERTED.
>
>Logically then, I would like to SELECT * FROM <TABLE>
>WHERE ....<Values entered here>, and then IF FOUND
>UPDATE <TABLE> SET .... <Values entered here> ELSE
>INSERT INTO <TABLE> VALUES <Values entered here>
>END IF;
>
>The IF statement gets rejected by the parser. So it would appear that
>PostgreSQL does not support an IF in this type of query, or maybe not at
>all.
>
>Does anyone have any suggestions as to how I can achieve this ?
>
>
>This message is privileged and confidential and intended for the addressee only. If you are not the intended recipient you may not disclose, copy or
>in any way use or publish the content hereof, which is subject to copyright.If you have received this in error, please destroy the original message
>and contact us at postmaster(at)cks(dot)co(dot)za(dot) Any views expressed in this message
>are those of the individual sender, except where the sender specifically
>states them to be the view of Computerkit Retail Systems, its subsidiaries or
>associates. Please note that the recipient must scan this e-mail and attachments for viruses. We accept no liability of whatever nature for any loss,
>liability,damage or expense resulting directly or indirectly from this transmission
>of this message and/or attachments.
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2003-08-19 08:10:31 Re: Mailing list in French
Previous Message Jules Alberts 2003-08-19 08:06:39 move to usenet?