![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I am trying to find a way to stamp all of the rows affected by an update (or insert) with a unique value. |
|
At first I tried to do this as a trigger function. The problem with this solution is that if I dont have the function called for each row, I cannot modify those rows. if I DO have the function called for each row, how do they get the "change_number" they cannot simply call nextval() as it will be different for each row (they also couldn't call curval() because then who is ever calling nextval()?) |
#2
| |||
| |||
|
|
I am trying to find a way to stamp all of the rows affected by an update (or insert) with a unique value. For example, consider the following table: .... At first I tried to do this as a trigger function. |
As a nice bonus,
#3
| |||
| |||
|
|
CREATE OR REPLACE FUNCTION update_mtime() RETURNS TRIGGER LANGUAGE PLPGSQL AS 'BEGIN NEW.mtime = now(); RETURN NEW; END;'; CREATE TRIGGER people_update_mtime BEFORE UPDATE ON people FOR EACH ROW EXECUTE PROCEDURE update_mtime(); (I use a version of this for my incremental backup scheme) Now every update (or insert) will cause all the rows changed to have the same unique value. |
![]() |
| Thread Tools | |
| Display Modes | |
| |