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

Поиск
Список
Период
Сортировка
От novnov
Тема Re: Trigger function which inserts into table; values from lookup
Дата
Msg-id 10720190.post@talk.nabble.com
обсуждение исходный текст
Ответ на Re: Trigger function which inserts into table; values from lookup  (Raymond O'Donnell <rod@iol.ie>)
Ответы Re: Trigger function which inserts into table; values from lookup  ("William Leite Araújo" <william.bh@gmail.com>)
Список pgsql-general
No and update would not be needed; but the capability would be close enough,
I'd just skip the update, do nothing for that record.

But from the sound of it, the example you're suggesting involves a loop or
something of that order. I could have written this using a loop but thought
a bulk operation that essentially worked like "insert new rows for the set
and while doing so, silently skip inserts which would cause dupe key
violations". I explained all of this in the earlier messages. I thought it
might be more effenient to handle without a loop. I've been able to do this
kind of thing with other databases; essentially instruct the routine to
ignore errors silently, commit what it can commit.


Raymond O'Donnell wrote:
>
> 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@iol.ie
> ---------------------------------------------------------------
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
>

--
View this message in context:
http://www.nabble.com/Trigger-function-which-inserts-into-table--values-from-lookup-tf3784731.html#a10720190
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Trigger function which inserts into table; values from lookup
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: replace function in a query