After delete worked and the a foreach execute update seems to work best.
Below is a satisfactory test set.
-- create test table
CREATE TABLE test1 (
a int,
b int,
c int);
-- create resort function
CREATE OR REPLACE FUNCTION resort_test1() RETURNS TRIGGER AS '
DECLARE
eachrow RECORD;
On Wed, 22 Jun 2005, Russell Simpkins wrote:
Hello,
I have created a trigger function to update the sort_order column of a
mapping table. I have table a that has a many to many relation ship with
table b that is mapped as a_b where a_id, and b_id are the pk columns and
there is a
Stephan Szabo [EMAIL PROTECTED] writes:
CREATE TRIGGER u_test1 BEFORE DELETE ON portfolio.test1 FOR EACH ROW EXECUTE
PROCEDURE resort_test1();
I think this will work in an after delete trigger, but not in a before
delete trigger (and seems to in my tests). I'm not sure what the spec says
I suspect that if you read the spec carefully it would want a triggered
data change violation error raised here. My advice is not to use a
BEFORE trigger for this.
What would you recommend then. I am using Hibernate in my java application
and if the sort_order column (in this example
Stephan Szabo [EMAIL PROTECTED] writes:
Is there anything we have right now that will handle this kind of thing
without requiring either updating all the counts after a deletion in a
statement trigger or once per row updating all the counts for records with
the same a (doing something like
;
' language 'plpgsql';
that I will rejigger to the test table and try out.
Thanks for the input.
From: Tom Lane [EMAIL PROTECTED]
To: Stephan Szabo [EMAIL PROTECTED]
CC: Russell Simpkins [EMAIL PROTECTED],
pgsql-sql@postgresql.org
Subject: Re: [SQL] after delete trigger behavior Date: Wed, 22 Jun