From 0339de2b74284d8f770a49732f5687726a40d7e2 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Wed, 22 May 2013 21:05:02 -0400 Subject: [PATCH] Configure partitions through 2014. --- triggers/team_game_stats_ins_trg.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/triggers/team_game_stats_ins_trg.sql b/triggers/team_game_stats_ins_trg.sql index 6664003..b88ace9 100644 --- a/triggers/team_game_stats_ins_trg.sql +++ b/triggers/team_game_stats_ins_trg.sql @@ -1,12 +1,15 @@ CREATE OR REPLACE FUNCTION team_game_stats_ins() RETURNS TRIGGER AS $$ BEGIN + -- 2011 IF (NEW.create_dt >= DATE '2011-04-01' AND NEW.create_dt < DATE '2011-07-01') THEN INSERT INTO team_game_stats_2011Q2 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2011-07-01' AND NEW.create_dt < DATE '2011-10-01') THEN INSERT INTO team_game_stats_2011Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2011-10-01' AND NEW.create_dt < DATE '2012-01-01') THEN INSERT INTO team_game_stats_2011Q4 VALUES (NEW.*); + + -- 2012 ELSIF (NEW.create_dt >= DATE '2012-01-01' AND NEW.create_dt < DATE '2012-04-01') THEN INSERT INTO team_game_stats_2012Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2012-04-01' AND NEW.create_dt < DATE '2012-07-01') THEN @@ -15,10 +18,27 @@ BEGIN INSERT INTO team_game_stats_2012Q3 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2012-10-01' AND NEW.create_dt < DATE '2013-01-01') THEN INSERT INTO team_game_stats_2012Q4 VALUES (NEW.*); + + -- 2013 ELSIF (NEW.create_dt >= DATE '2013-01-01' AND NEW.create_dt < DATE '2013-04-01') THEN INSERT INTO team_game_stats_2013Q1 VALUES (NEW.*); ELSIF (NEW.create_dt >= DATE '2013-04-01' AND NEW.create_dt < DATE '2013-07-01') THEN INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2013-07-01' AND NEW.create_dt < DATE '2013-10-01') THEN + INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2013-10-01' AND NEW.create_dt < DATE '2013-01-01') THEN + INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + + -- 2014 + ELSIF (NEW.create_dt >= DATE '2014-01-01' AND NEW.create_dt < DATE '2014-04-01') THEN + INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2014-04-01' AND NEW.create_dt < DATE '2014-07-01') THEN + INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2014-07-01' AND NEW.create_dt < DATE '2014-10-01') THEN + INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + ELSIF (NEW.create_dt >= DATE '2014-10-01' AND NEW.create_dt < DATE '2015-10-01') THEN + INSERT INTO team_game_stats_2013Q2 VALUES (NEW.*); + ELSE RAISE EXCEPTION 'Date out of range. Fix the team_game_stats_ins() trigger!'; END IF; -- 2.39.2