Trigger (Transaction related)

From: "Harpreet Dhaliwal" <harpreet(dot)dhaliwal01(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Trigger (Transaction related)
Date: 2006-09-01 06:51:59
Message-ID: d86a77ef0608312351h175bede8v2d537380f096c10d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-09-01 07:00:17 Re: Trigger (Transaction related)
Previous Message Martijn van Oosterhout 2006-09-01 06:32:23 Re: SPI_execute (result of a select statement)