I tried to answer the previous version of this mail, but I don't understand it. Let me see if my questions trigger something for you, though.
On Mon, Jul 16, 2007 at 12:32:07PM +0200, De Leeuw Guy wrote: > > a table : > CREATE TABLE test ( > code int8 NOT NULL, > qte float8, > CONSTRAINT test_pkey PRIMARY KEY (code) > ) > CREATE TRIGGER trig_update_sum BEFORE INSERT OR UPDATE OR DELETE ON > table_test > FOR EACH ROW EXECUTE PROCEDURE gd_trigfunc_before_buildsum(); > EOF > > code maybe 1,2,3 > 3 = sum of 1 & 2 > > the trigger make the sum : > if event = INSERT code = 3 ==> skip > if event = INSERT code = 1 or 2 > if select code 3 exist ? yes = update qte code 3 + qte code x > no = insert qte to code 3 So if I am reading you correctly, IF code IN (1,2) THEN {do something}? What do you do then? I don't get this part. > INSERT INTO test VALUES (1, 50); > INSERT INTO test VALUES (3, 60); > ok code 3 = 110 > > psql : delete from test; > code 1 & 2 deleted > code 3 = 50 I don't see how this is possible either. You just deleted from test; how can you hae anything left in there? > maybe this is because these commands start a transaction with a cache > and each time that I request a select for a sum code that are on the > cache the value returned are not the real new value. No, but a trigger that executes SQL can cause the trigger to fire again. Are you sure that's not happening? A -- Andrew Sullivan | [EMAIL PROTECTED] Everything that happens in the world happens at some place. --Jane Jacobs ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings