Re: Insert with query - Mailing list pgsql-general

From Kevin Grittner
Subject Re: Insert with query
Date
Msg-id 1370103760.74333.YahooMailNeo@web162903.mail.bf1.yahoo.com
Whole thread Raw
In response to Re: Insert with query  (Adrian Klaver <adrian.klaver@gmail.com>)
Responses Re: Insert with query
List pgsql-general
Adrian Klaver <adrian.klaver@gmail.com> wrote:
> On 06/01/2013 06:47 AM, Kevin Grittner wrote:

>> Currently on an AFTER ... FOR EACH ROW we fire the trigger once
>> *for* each affected row, that's true.  But we don't do it
>> immediately after the *triggering event* -- we do it immediately
>> after the *data change statement*.  The issue isn't how many times
>> we execute the trigger, or with what parameters, but *when* it
>> runs.
>
> Aah, that was the part I was missing. So to see if I understand, in the
> OPs case:
>
> 1) The first case worked as Juliano expected because the INSERTs where
> done in a loop where each INSERT was a discrete statement and there was
> a 1:1 correspondence between statement and triggering event.
>
> 2) The second case did not work as expected because the INSERTs where
> wrapped up in a single statement and the AFTER triggers ran for each row
> after all the rows where inserted not after each row was inserted.

Exactly.

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Insert with query
Next
From: Adrian Klaver
Date:
Subject: Re: Insert with query