From: | Juan Pablo Cook <juampick(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Trigger of Transaction |
Date: | 2013-04-02 03:41:12 |
Message-ID: | CAKge45Ky+qv9Dei_-CSqksAypHT1uOViaWKuCf4K8xig-fVg1A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
Hi everyone! I need your help with this problem.
I'm using PostgreSQL *9.2 Server* & the latest jdbc
driver: postgresql-9.2-1002.jdbc4.jar
I have a many to one relation. I have this piece of code:
con.setAutoCommit(false); //transaction block start
// Make an insert to one table (Vector)
// After that I insert the childs of the first table with their parent_id
like the FK.
con.commit(); //transaction block end
I have this Trigger:
CREATE *TRIGGER *trigger_update_index *AFTER INSERT*
ON "Vector" FOR EACH ROW
EXECUTE PROCEDURE update_index();
CREATE OR REPLACE FUNCTION *update_index*() RETURNS *TRIGGER *AS
$update_index$
DECLARE
BEGIN
-- Make something
END;
$update_index$ LANGUAGE plpgsql;
What's the problem? that when the trigger fire only the Parent (Vector) was
inserted an not the childs :S so I need that records to be inserted to work
in my function.
I'm trying to make a Trigger, only to *execute after ALL the transaction*.
So, after all the INSERTs INTO (like 5 or 10) I want to launch my function.
I found some information in google about this: "*Constraint Trigger*", that
perhaps I can tell some rules before triggering but I don't know if it is
what I need to and also don't know how to code that.
I appreciate your help a lot.
Thanks ;)
JP Cook
From | Date | Subject | |
---|---|---|---|
Next Message | CauBa | 2013-04-02 05:46:45 | O_O |
Previous Message | Jeff Davis | 2013-04-02 03:29:37 | Re: Money casting too liberal? |
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Van Dyk | 2013-04-02 15:29:30 | Re: [GENERAL] Trigger of Transaction |
Previous Message | Juan Pablo Cook | 2013-04-01 21:19:41 | Re: JDBC Array double precision [] error |