Search Postgresql Archives

Trigger in partitioned table

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

 



Hi,

When adding sets of new child tables to a artitioned table, I need to
update the triggers with new dates added as new condition. See sample
below.

My question is, what will happen if the update to the trigger happen
at the same time as insert operation to the master table?

CREATE OR REPLACE FUNCTION t_agg_billing()
  RETURNS "trigger" AS
$BODY$
DECLARE
BEGIN
	IF (TG_OP = 'INSERT') THEN
		IF NEW.CallDate = 20071001 THEN
			INSERT INTO z_agg_billing_d_20071001 VALUES ( NEW.* );
		ELSEIF NEW.CallDate = 20071002 THEN
			INSERT INTO z_agg_billing_d_20071002 VALUES ( NEW.* );
		ELSEIF NEW.CallDate = 20071003 THEN
			INSERT INTO z_agg_billing_d_20071003 VALUES ( NEW.* );
                                 ...
                                 ...
                                 ...

		END IF;
	END IF;
	RETURN NULL;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION t_agg_billing() OWNER TO sa;

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[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