Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Rafal Pietrak
Perfect! Thenx! -R On Thu, 2007-01-11 at 12:26 -0800, Adrian Klaver wrote: > On Thursday 11 January 2007 10:26 am, Rafal Pietrak wrote: > > On Thu, 2007-01-11 at 15:10 +0100, Alban Hertroys wrote: > > > Rafal Pietrak wrote: > > > > Hi! > > > > > > > > I'm re-posting this message again in hope som

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Adrian Klaver
On Thursday 11 January 2007 10:26 am, Rafal Pietrak wrote: > On Thu, 2007-01-11 at 15:10 +0100, Alban Hertroys wrote: > > Rafal Pietrak wrote: > > > Hi! > > > > > > I'm re-posting this message again in hope someone would have a look at > > > the case again. .. it's pending. > > > > You were given

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Tom Lane
Martijn van Oosterhout writes: > On Thu, Jan 11, 2007 at 07:26:32PM +0100, Rafal Pietrak wrote: >> So may be "SET CONSTRAINTS DEFERRED " should be used somehow >> differently? I've never had any use for that construct, may be I miss >> something? > Only at the beginning of a transaction and

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Martijn van Oosterhout
On Thu, Jan 11, 2007 at 07:26:32PM +0100, Rafal Pietrak wrote: > Well. I were, but probably I'm doing something wrong with 'deferring the > trigger'. When I put: > > "SET CONSTRAINTS ALL DEFERRED ; " > > *before* the UPDATE statement *within* the trigger function (just after > BEGIN statement t

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Rafal Pietrak
On Thu, 2007-01-11 at 15:10 +0100, Alban Hertroys wrote: > Rafal Pietrak wrote: > > Hi! > > > > I'm re-posting this message again in hope someone would have a look at > > the case again. .. it's pending. > > You were given a solution; defer the foreign key constraint. Well. I were, but probab

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Alban Hertroys
Rafal Pietrak wrote: > Hi! > > I'm re-posting this message again in hope someone would have a look at > the case again. .. it's pending. You were given a solution; defer the foreign key constraint. Alternatively, you may want to re-think your trigger function so that it does things in the rig

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Martijn van Oosterhout
On Thu, Jan 11, 2007 at 01:01:24PM +0100, Rafal Pietrak wrote: > Hi! > > I'm re-posting this message again in hope someone would have a look at > the case again. .. it's pending. Well, I can't help with the details because I can't see what you're trying to do, but I'm fairly sure you can't cha

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-11 Thread Rafal Pietrak
Hi! I'm re-posting this message again in hope someone would have a look at the case again. .. it's pending. In postgres v7.2 I had a trigger function launched BEFORE INSERT, which did everything I needed (like an UPDATE of other table inside of that trigger function, and adjustment of the INSE

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-09 Thread Rafal Pietrak
On Tue, 2007-01-09 at 10:44 -0500, Tom Lane wrote: > Rafal Pietrak <[EMAIL PROTECTED]> writes: > > 1. either the new value of "test_days.dnia" as already present in the > > NEW row, is not visible to "UPDATE test_utarg" sub-statement of the same > > transaction. But earlier versions of Postgres did

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-09 Thread Tom Lane
Rafal Pietrak <[EMAIL PROTECTED]> writes: > 1. either the new value of "test_days.dnia" as already present in the > NEW row, is not visible to "UPDATE test_utarg" sub-statement of the same > transaction. But earlier versions of Postgres did allow for that > visibility. > 2. or the constrainets in e

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-08 Thread Rafal Pietrak
Uuups... That's what I feared of. I was a bit hasty and nervous after I've discovered, that the old schema doesn't work. Sory for that. An yet, the original question remain. After I've change the TRIGGER to "FOR EACH ROW", I get: --- database=# C

Re: [GENERAL] TRIGGER BEFORE INSERT

2007-01-08 Thread Jerry Sievers
Rafal Pietrak <[EMAIL PROTECTED]> writes: > Hi All! > > I have some old piece of code, that worked two years ago (Postgres > version 7.2, I think), but doesn't work within Postgres 8.1.4 now. > > The story is, that I have a trigger on a table (business day > statistics), that is fired before ins

[GENERAL] TRIGGER BEFORE INSERT

2007-01-08 Thread Rafal Pietrak
Hi All! I have some old piece of code, that worked two years ago (Postgres version 7.2, I think), but doesn't work within Postgres 8.1.4 now. The story is, that I have a trigger on a table (business day statistics), that is fired before insert; it updates another table (detailed transaction log),

Re: [GENERAL] Trigger before insert

2004-11-25 Thread ON.KG
Hi! >> How could i stop Inserting record into table by some condition? RH> RETURN null when using a before trigger. Or raise an exception to abort RH> the whole transaction. Thanx ;) RETURN NULL works so as i need ---(end of broadcast)--- TIP 5:

Re: [GENERAL] Trigger before insert

2004-11-25 Thread Richard Huxton
ON.KG wrote: How could i stop Inserting record into table by some condition? RETURN null when using a before trigger. Or raise an exception to abort the whole transaction. -- Richard Huxton Archonet Ltd ---(end of broadcast)--- TIP 1: subscribe

[GENERAL] Trigger before insert

2004-11-25 Thread ON.KG
Hi all, === CREATE FUNCTION trigger_test_func() RETURNS trigger AS ' DECLARE cnt int4; BEGIN SELECT INTO cnt COUNT(*) FROM table_test WHERE ip = new.ip; IF cnt > 50 THEN -- THERE THE "INSERT" HAS TO BE STOPED END IF; RETURN new; END;'