Trigger does not behave as expected

From: Goboxe <hadzramin(dot)ar(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Trigger does not behave as expected
Date: 2008-09-12 03:34:54
Message-ID: 3874a4e2-e310-4158-9c55-16b4e11ec5e6@x35g2000hsb.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-09-12 03:48:06 Re: [GENERAL] PostgreSQL TPC-H test result?
Previous Message Scott Marlowe 2008-09-12 03:34:18 Re: declare column update expression