Re: [SQL] [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them

2010-07-27 Thread Torsten Zühlsdorff
Tom Lane schrieb: =?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: I have defined an BEFORE UPDATE trigger. The trigger catch every update, change some columns of the new row, make an insert of the new row and returns null to abort the update. Why in the world would you do that? Just return t

Re: [SQL] [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them

2010-07-26 Thread Torsten Zühlsdorff
Hey Dmitriy, thanks for your reply. I think, its would be better to use rule on update instead of the trigger in such case as you. I've played the whole weekend with the rule-system, but it didn't work for my case. I have a dynamic trigger, which takes cares about revision of rows for every

[SQL] [TRIGGER] Returning values from BEFORE UPDATE trigger, without using them

2010-07-23 Thread Torsten Zühlsdorff
Hello, i have a non-trival problem and i do not believe that it is solvable. I have defined an BEFORE UPDATE trigger. The trigger catch every update, change some columns of the new row, make an insert of the new row and returns null to abort the update. All fine till here :) Now the problem:

Re: [SQL] strangest thing happened

2010-07-08 Thread Torsten Zühlsdorff
Joe Conway schrieb: I am the only developer, DBA etc.. for a small project. Today (yesterday was everything was perfect) many of the sequence numbers fell behind what is the actual PK value. For example the invoice PK sequence current value = 1056 but the table PK was 1071. Nobody (other t

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-17 Thread Torsten Zühlsdorff
Jasen Betts schrieb: On 2010-05-11, Torsten Zühlsdorff wrote: Hello, i have a problem with a trigger written in pl/pgsql. It looks like this: CREATE OR REPLACE FUNCTION versionize() RETURNS TRIGGER AS $$ BEGIN NEW.revision := addContentRevision (OLD.content_id, OLD.revision

[SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Torsten Zühlsdorff
Hello, i have a problem with a trigger written in pl/pgsql. It looks like this: CREATE OR REPLACE FUNCTION versionize() RETURNS TRIGGER AS $$ BEGIN NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAM

Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Torsten Zühlsdorff
Tom Lane schrieb: =?ISO-8859-15?Q?Torsten_Z=FChlsdorff?= writes: NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAME || ' SELECT $1 ' USING NEW; */ RETURN NULL; This seems like the

[SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Torsten Zühlsdorff
Hello, i have a problem with a trigger written in pl/pgsql. It looks like this: CREATE OR REPLACE FUNCTION versionize() RETURNS TRIGGER AS $$ BEGIN NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAM

[SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Torsten Zühlsdorff
Hello, i have a problem with a trigger written in pl/pgsql. It looks like this: CREATE OR REPLACE FUNCTION versionize() RETURNS TRIGGER AS $$ BEGIN NEW.revision := addContentRevision (OLD.content_id, OLD.revision); /* not working line, just a stub: EXECUTE 'INSERT INTO ' || TG_TABLE_NAM