Show
Ignore:
Timestamp:
10/02/09 18:50:32 (5 years ago)
Author:
Robert Treat <robert@omniti.com>
git-committer:
Robert Treat <robert@omniti.com> 1254509432 +0000
git-parent:

[1cb12d1bd5a9021a4249d44f0a80de3a36e848c9]

git-author:
Robert Treat <robert@omniti.com> 1254509432 +0000
Message:

trigger function for check_archive_changelog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/sprocs/noit.check_archive_log_changes.sql

    rd0f32e9 raa30d31  
    1 -- formerly stratcon.mv_loading_dock_check_s 
     1-- formerly check_currently 
     2 
     3set search_path = noit;  
     4 
     5CREATE OR REPLACE FUNCTION check_archive_log_changes() 
     6RETURNS trigger  
     7AS $$ 
     8DECLARE 
     9    v_remote_address INET; 
     10    v_target TEXT; 
     11    v_name TEXT; 
     12BEGIN 
     13 
     14IF TG_OP = 'INSERT' THEN 
     15    SELECT remote_address,target,name FROM  check_currently WHERE sid = NEW.sid AND id=NEW.id  
     16        INTO v_remote_address,v_target,v_name; 
     17 
     18    IF v_remote_address IS DISTINCT FROM NEW.remote_address OR v_target IS DISTINCT FROM NEW.target OR v_name IS DISTINCT FROM NEW.name   THEN 
     19         
     20        DELETE from check_currently WHERE sid = NEW.sid AND id=NEW.id; 
     21         
     22        INSERT INTO check_currently (sid,remote_address,whence,id,target,module,name) 
     23            VALUES (NEW.sid,NEW.remote_address,NEW.whence,NEW.id,NEW.target,NEW.module,NEW.name);  
     24 
     25    END IF; 
     26 
     27ELSE 
     28        RAISE EXCEPTION 'Something wrong with check_archive_log_changes'; 
     29END IF; 
     30 
     31    RETURN NULL; 
     32 
     33END 
     34$$ LANGUAGE plpgsql 
     35SECURITY DEFINER 
     36
     37