Changeset 601c99b9ea251da8e30fe85e055c372a540491ee

Show
Ignore:
Timestamp:
06/06/08 20:42:16 (7 years ago)
Author:
Denish Patel <denish@omniti.com>
git-committer:
Denish Patel <denish@omniti.com> 1212784936 +0000
git-parent:

[5e653fe60dcc517ff76c1f3bb82cee19b3c51fa5]

git-author:
Denish Patel <denish@omniti.com> 1212784936 +0000
Message:

Exception handling UNIQUE_VIOLATION in log_whence_change_log function.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/schema.sql

    rd95460a r601c99b  
    337337DECLARE 
    338338v_whence timestamptz; 
     339v_whence_5 timestamptz; 
    339340v_sid integer; 
    340341v_name text; 
    341342BEGIN 
    342343IF TG_OP = 'INSERT' THEN 
    343    SELECT whence FROM stratcon.log_whence_s WHERE whence=date_trunc('H',NEW.WHENCE) + (round(extract('minute' from NEW.WHENCE)/5)*5) * '1 minute'::interval and interval='5 minutes' 
     344  
     345 v_whence_5:=date_trunc('H',NEW.WHENCE) + (round(extract('minute' from NEW.WHENCE)/5)*5) * '1 minute'::interval; 
     346  
     347   SELECT whence FROM stratcon.log_whence_s WHERE whence=v_whence_5 and interval='5 minutes' 
    344348     INTO v_whence; 
     349      
    345350   IF NOT FOUND THEN 
    346        INSERT INTO  stratcon.log_whence_s VALUES(date_trunc('H',NEW.WHENCE) + (round(extract('minute' from NEW.WHENCE)/5)*5) * '1 minute'::interval,'5 minutes'); 
     351      BEGIN 
     352       INSERT INTO  stratcon.log_whence_s VALUES(v_whence_5,'5 minutes'); 
     353       EXCEPTION 
     354        WHEN UNIQUE_VIOLATION THEN 
     355        -- do nothing  
     356      END; 
    347357    END IF; 
    348358 
     
    354364 
    355365END IF; 
    356  
    357366    RETURN NULL; 
    358 EXCEPTION 
    359         WHEN RAISE_EXCEPTION THEN 
    360                RETURN NULL; 
    361         WHEN OTHERS THEN 
    362                 RETURN NULL; 
    363367END 
    364 $$ 
    365     LANGUAGE plpgsql; 
     368$$    LANGUAGE plpgsql; 
    366369 
    367370-- 5 minutes rollup