Re: Trigger function which inserts into table; values from lookup

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: novnov <novnovice(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger function which inserts into table; values from lookup
Date: 2007-05-21 12:21:59
Message-ID: 46518EE7.8090705@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21/05/2007 05:26, novnov wrote:

> OK, but, how do I set this up to do what I need? I want an insert that would
> create a dupe key to be rolled back, and inserts that would not create dupe
> keys to be committed.

Do you specifically need it in a trigger? I seem to recall an example in
the docs for pl/pgsql demonstrating a function to do something like this
- I think it tries an INSERT, and when a duplicate key raises an
exception, it does an update instead. - You could easily adapt this to
your purposes.

Ray.

---------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
---------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-05-21 13:26:27 Re: Role members
Previous Message William Leite Araújo 2007-05-21 11:44:23 Re: replace function in a query