Re: INSERT or UPDATE - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: INSERT or UPDATE
Date
Msg-id 20080818105028.GA2567@a-kretschmer.de
Whole thread Raw
In response to INSERT or UPDATE  (Andreas Kraftl <andreas.kraftl@kraftl.at>)
List pgsql-sql
am  Mon, dem 18.08.2008, um  9:44:48 +0200 mailte Andreas Kraftl folgendes:
> But there is also the possibility, that one row is available. Means that
> i need an UPDATE instead of the INSERT.
> 
> Is it in SQL possible to decide if there is an UPDATE or an INSERT or
> must i program something with PHP for example?

You can use a own function for this, see
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
Example 38-1. Exceptions with UPDATE/INSERT


HTH, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


pgsql-sql by date:

Previous
From: Andreas Kraftl
Date:
Subject: INSERT or UPDATE
Next
From: "Nacef LABIDI"
Date:
Subject: Select function with set return type