Trigger does not behave as expected - Mailing list pgsql-general

From Goboxe
Subject Trigger does not behave as expected
Date
Msg-id 3874a4e2-e310-4158-9c55-16b4e11ec5e6@x35g2000hsb.googlegroups.com
Whole thread Raw
Responses Re: Trigger does not behave as expected  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
Hi,

I have a trigger as below.

I am wondering why when I tried to insert to master table with date=
20080908,
the trigger does not insert to z_agg_tmcarr_pfx_gtwy_cc_w_20080908.

Is that something wrong with the statement "ELSEIF NEW.CallDate >=
20080908 AND NEW.CallDate <= 20080914  THEN"?


--------------------------------------------------

CREATE OR REPLACE FUNCTION t_agg_tmcarr_pfx_gtwy_cc()
  RETURNS "trigger" AS
$BODY$
DECLARE
BEGIN
    IF (TG_OP = 'INSERT') THEN
        IF NEW.CallDate >= 20080901 AND NEW.CallDate <= 20080907 THEN
            INSERT INTO z_agg_tmcarr_pfx_gtwy_cc_w_20080901 VALUES ( NEW.* );
        ELSEIF NEW.CallDate >= 20080908 AND NEW.CallDate <= 20080914  THEN
            INSERT INTO z_agg_tmcarr_pfx_gtwy_cc_w_20080908 VALUES ( NEW.* );
        ELSEIF NEW.CallDate >= 20080915 AND NEW.CallDate <= 20080921  THEN
            INSERT INTO z_agg_tmcarr_pfx_gtwy_cc_w_20080915 VALUES ( NEW.* );
        END IF;
    END IF;
    RETURN NULL;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION t_agg_tmcarr_pfx_gtwy_cc() OWNER TO sa;

pgsql-general by date:

Previous
From: lighthouse.software@gmail.com
Date:
Subject: Re: DbLink Compilation on Solaris 10
Next
From: btober@mail.ct.metrocast.net
Date:
Subject: pg_dumpall problem when roles have default schemas