On Mittwoch, 7. Mai 2008 Tom Lane wrote: > No, the trigger command has to be BEFORE UPDATE not AFTER UPDATE for > this to work. This is definitely the better way though because the > row only gets updated once, not stored and then updated again > (in fact, I think you could get into an infinite loop if an AFTER > UPDATE trigger tries to update the row again). OK, here's the final correct syntax (examples missed the () at the function name): CREATE FUNCTION awlupdate() RETURNS TRIGGER AS ' BEGIN NEW.lastupdate = now(); RETURN NEW; END' LANGUAGE plpgsql; CREATE TRIGGER awlupdate BEFORE UPDATE ON awl FOR EACH ROW EXECUTE PROCEDURE awlupdate(); Thanks for your help! It's a bit complex just for an update, but it works. :-) mfg zmi -- // Michael Monnerie, Ing.BSc ----- http://it-management.at // Tel: 0676/846 914 666 .network.your.ideas. // PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import" // Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4 // Keyserver: www.keyserver.net Key-ID: 1C1209B4
Attachment:
signature.asc
Description: This is a digitally signed message part.