[PyGreSQL] How to insert a record if it doesn't exist else update it ?
Christoph Zwerschke
cito at online.de
Wed Dec 19 16:17:00 EST 2007
fdu.xiaojf at gmail.com wrote:
> Hi all,
>
> What I want to do is:
> if a record already exists in the table, update it
> if a record doesn't exist, insert it into the table
>
> I know that there is a ON DUPLICATE clause with MySQL, so I'm wondering is
> there a corresponding way to do this in PostgreSQL ?
You can find something equivalent in Example 37-1 in the Postgres Docs:
http://www.postgresql.org/docs/8.2/interactive/plpgsql-control-structures.html
Unfortunately, Postgres so far does not support the "MERGE" statement as
newer versions of Oracle or SQL server do.
-- Chris
(And as D'Arcy already mentioned, the PostgreSQL mailing list is a
better place for such questions.)
More information about the PyGreSQL
mailing list