Trigger (Transaction related) - Mailing list pgsql-general

From Harpreet Dhaliwal
Subject Trigger (Transaction related)
Date
Msg-id d86a77ef0608312351h175bede8v2d537380f096c10d@mail.gmail.com
Whole thread Raw
Responses Re: Trigger (Transaction related)
Re: Trigger (Transaction related)
List pgsql-general
Hi,
I've written a trigger after insert on a table (parser) and the trigger calls a function that dynamically loads a shared object written in C.

This shared object intends to use the newly inserted row in the table on which trigger is written and insert values in another table, something like this,

sprintf(buffer, "INSERT INTO headers (id, header_content) VALUES ( %d, SELECT contents FROM parser WHERE id = %d ), id, id);
SPI_exec(buffer,0).

Above line of code is not able to read the values of newly inserted code i.e
SELECT contents FROM parser WHERE id = %d
and throws an error.

Is it because its still the same transaction going on and the insert fired on parser talbe won't be reflected in the select query in the shared object which is a part of the same transaction???

Regards,

~Harpreet


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: SPI_execute (result of a select statement)
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Trigger (Transaction related)