From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Harpreet Dhaliwal <harpreet(dot)dhaliwal01(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: [NOVICE] DB insert Error |
Date: | 2006-08-16 17:38:41 |
Message-ID: | 20060816173841.GA72967@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
On Wed, Aug 16, 2006 at 02:59:23AM -0400, Harpreet Dhaliwal wrote:
> I mean can we call a stored procedure as an action of a trigger?
You'll need to write a trigger function that calls the non-trigger
function (what you're referring to as "stored procedure"). Example:
CREATE FUNCTION trigger_function() RETURNS trigger AS $$
BEGIN
PERFORM other_function();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_name BEFORE INSERT OR UPDATE ON table_name
FOR EACH ROW EXECUTE PROCEDURE trigger_function();
> Its actually something like the trigger should start a C function after
> insert and the C function has the ECPG code for some more inserts.
> Its similar to the way we dynamically load a shared library while
> executing a stored procedure, as in , executing a fucntion in C file using
> stored procedure/ function.
You have a server-side C function that uses ECPG? Is there a reason
you're not using SPI? Are you connecting to a different server?
Or by "function" do you really mean "program," meaning a separate
executable?
http://www.postgresql.org/docs/8.1/interactive/spi.html
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2006-08-16 17:44:11 | Re: Weird join result |
Previous Message | Jeff Davis | 2006-08-16 17:36:54 | Re: Determine Transactions Per Second |
From | Date | Subject | |
---|---|---|---|
Next Message | Jasbinder Bali | 2006-08-16 18:42:46 | Re: [NOVICE] DB insert Error |
Previous Message | Tom Lane | 2006-08-16 17:14:57 | Re: libpq Describe Extension [WAS: Bytea and perl] |