Search Postgresql Archives

Trigger does not behave as expected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux