dbTalk Databases Forums  

Trigger using 'if NEW = OLD'

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Trigger using 'if NEW = OLD' in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Colin Fox
 
Posts: n/a

Default Trigger using 'if NEW = OLD' - 03-03-2004 , 06:39 AM






I've got a trigger function that gets executed after an insert or an
update. It basically just creates a copy of the row in a history table.

However, there are cases when a row will be updated to be the same as it
was - in other words, no change. In these cases, the history is useless
and taking up space.

So I want the procedure to start with:

IF NEW = OLD then
return NEW;
end if;

thus exiting before the history record gets created.

However, if I do that, I get:
WARNING: line 6 at if
ERROR: NEW used in non-rule query

What is a non-rule query?

I'm led to believe by the documentation and other postings I've seen
archived on the web that this should be possible.

Am I doing something wrong, or do I have to do it the long way around
(field by field comparison)?

Thanks,
cf

--
Colin Fox
President
CF Consulting Inc.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.