Re: Create or replace row in table - Mailing list pgsql-novice

From Mladen Gogala
Subject Re: Create or replace row in table
Date
Msg-id 4C7F1FD0.2040507@vmsinfo.com
Whole thread Raw
In response to Create or replace row in table  ("Charles Holleran " <scorpdaddy@hotmail.com>)
List pgsql-novice
Charles Holleran wrote:
> Please pardon the total nubie question.
>
> There is a nice syntax for functions,  "CREATE OR REPLACE FUNCTION xyz ..."
>
> What is the best syntax to create or replace a row in a table?
>
> Specifically: Update row in table t if row exists in table t else insert row in table t with source rows from
temporarytable s of same type as t. 

INSERT or UPDATE should do the trick, especially when combined with
plpgsql, exceptions and basic error handling. You should be able to find
the relevant material here:
http://developer.postgresql.org/pgdocs/postgres/plpgsql-control-structures.html
and here:
http://developer.postgresql.org/pgdocs/postgres/errcodes-appendix.html

--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


pgsql-novice by date:

Previous
From: "Charles Holleran "
Date:
Subject: Create or replace row in table
Next
From: A B
Date:
Subject: operator @> does not work with box.