-CREATE OR REPLACE FUNCTION games_ins()\r
+CREATE OR REPLACE FUNCTION games_ins()\r
RETURNS TRIGGER AS $$\r
BEGIN\r
- IF (create_dt >= DATE '2011-04-01' AND create_dt < DATE '2011-07-01') THEN\r
+ IF (NEW.create_dt >= DATE '2011-04-01' AND NEW.create_dt < DATE '2011-07-01') THEN\r
INSERT INTO games_2011Q2 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2011-07-01' AND create_dt < DATE '2011-10-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2011-07-01' AND NEW.create_dt < DATE '2011-10-01') THEN\r
INSERT INTO games_2011Q3 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2011-10-01' AND create_dt < DATE '2012-01-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2011-10-01' AND NEW.create_dt < DATE '2012-01-01') THEN\r
INSERT INTO games_2011Q4 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-01-01' AND create_dt < DATE '2012-04-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-01-01' AND NEW.create_dt < DATE '2012-04-01') THEN\r
INSERT INTO games_2012Q1 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-04-01' AND create_dt < DATE '2012-07-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-04-01' AND NEW.create_dt < DATE '2012-07-01') THEN\r
INSERT INTO games_2012Q2 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-07-01' AND create_dt < DATE '2012-10-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-07-01' AND NEW.create_dt < DATE '2012-10-01') THEN\r
INSERT INTO games_2012Q3 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-10-01' AND create_dt < DATE '2013-01-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-10-01' AND NEW.create_dt < DATE '2013-01-01') THEN\r
INSERT INTO games_2012Q4 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2013-01-01' AND create_dt < DATE '2013-04-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2013-01-01' AND NEW.create_dt < DATE '2013-04-01') THEN\r
INSERT INTO games_2013Q1 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2013-04-01' AND create_dt < DATE '2013-07-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2013-04-01' AND NEW.create_dt < DATE '2013-07-01') THEN\r
INSERT INTO games_2013Q2 VALUES (NEW.*);\r
ELSE\r
RAISE EXCEPTION 'Date out of range. Fix the games_ins() trigger!';\r
END;\r
$$\r
LANGUAGE plpgsql;\r
+\r
+DROP TRIGGER IF EXISTS games_ins_trg ON xonstat.games;\r
+CREATE TRIGGER games_ins_trg\r
+ BEFORE INSERT on xonstat.games\r
+ FOR EACH ROW EXECUTE PROCEDURE games_ins();\r
-CREATE OR REPLACE FUNCTION player_game_stats_ins()\r
+CREATE OR REPLACE FUNCTION player_game_stats_ins()\r
RETURNS TRIGGER AS $$\r
BEGIN\r
- IF (create_dt >= DATE '2011-04-01' AND create_dt < DATE '2011-07-01') THEN\r
+ IF (NEW.create_dt >= DATE '2011-04-01' AND NEW.create_dt < DATE '2011-07-01') THEN\r
INSERT INTO player_game_stats_2011Q2 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2011-07-01' AND create_dt < DATE '2011-10-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2011-07-01' AND NEW.create_dt < DATE '2011-10-01') THEN\r
INSERT INTO player_game_stats_2011Q3 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2011-10-01' AND create_dt < DATE '2012-01-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2011-10-01' AND NEW.create_dt < DATE '2012-01-01') THEN\r
INSERT INTO player_game_stats_2011Q4 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-01-01' AND create_dt < DATE '2012-04-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-01-01' AND NEW.create_dt < DATE '2012-04-01') THEN\r
INSERT INTO player_game_stats_2012Q1 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-04-01' AND create_dt < DATE '2012-07-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-04-01' AND NEW.create_dt < DATE '2012-07-01') THEN\r
INSERT INTO player_game_stats_2012Q2 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-07-01' AND create_dt < DATE '2012-10-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-07-01' AND NEW.create_dt < DATE '2012-10-01') THEN\r
INSERT INTO player_game_stats_2012Q3 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-10-01' AND create_dt < DATE '2013-01-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-10-01' AND NEW.create_dt < DATE '2013-01-01') THEN\r
INSERT INTO player_game_stats_2012Q4 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2013-01-01' AND create_dt < DATE '2013-04-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2013-01-01' AND NEW.create_dt < DATE '2013-04-01') THEN\r
INSERT INTO player_game_stats_2013Q1 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2013-04-01' AND create_dt < DATE '2013-07-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2013-04-01' AND NEW.create_dt < DATE '2013-07-01') THEN\r
INSERT INTO player_game_stats_2013Q2 VALUES (NEW.*);\r
ELSE\r
RAISE EXCEPTION 'Date out of range. Fix the player_game_stats_ins() trigger!';\r
END;\r
$$\r
LANGUAGE plpgsql;\r
+\r
+DROP TRIGGER IF EXISTS player_game_stats_ins_trg ON xonstat.player_game_stats;\r
+CREATE TRIGGER player_game_stats_ins_trg\r
+ BEFORE INSERT on xonstat.player_game_stats\r
+ FOR EACH ROW EXECUTE PROCEDURE player_game_stats_ins();\r
-CREATE OR REPLACE FUNCTION player_weapon_stats_ins()\r
+CREATE OR REPLACE FUNCTION player_weapon_stats_ins()\r
RETURNS TRIGGER AS $$\r
BEGIN\r
- IF (create_dt >= DATE '2011-04-01' AND create_dt < DATE '2011-07-01') THEN\r
+ IF (NEW.create_dt >= DATE '2011-04-01' AND NEW.create_dt < DATE '2011-07-01') THEN\r
INSERT INTO player_weapon_stats_2011Q2 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2011-07-01' AND create_dt < DATE '2011-10-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2011-07-01' AND NEW.create_dt < DATE '2011-10-01') THEN\r
INSERT INTO player_weapon_stats_2011Q3 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2011-10-01' AND create_dt < DATE '2012-01-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2011-10-01' AND NEW.create_dt < DATE '2012-01-01') THEN\r
INSERT INTO player_weapon_stats_2011Q4 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-01-01' AND create_dt < DATE '2012-04-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-01-01' AND NEW.create_dt < DATE '2012-04-01') THEN\r
INSERT INTO player_weapon_stats_2012Q1 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-04-01' AND create_dt < DATE '2012-07-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-04-01' AND NEW.create_dt < DATE '2012-07-01') THEN\r
INSERT INTO player_weapon_stats_2012Q2 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-07-01' AND create_dt < DATE '2012-10-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-07-01' AND NEW.create_dt < DATE '2012-10-01') THEN\r
INSERT INTO player_weapon_stats_2012Q3 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2012-10-01' AND create_dt < DATE '2013-01-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2012-10-01' AND NEW.create_dt < DATE '2013-01-01') THEN\r
INSERT INTO player_weapon_stats_2012Q4 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2013-01-01' AND create_dt < DATE '2013-04-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2013-01-01' AND NEW.create_dt < DATE '2013-04-01') THEN\r
INSERT INTO player_weapon_stats_2013Q1 VALUES (NEW.*);\r
- ELSIF (create_dt >= DATE '2013-04-01' AND create_dt < DATE '2013-07-01') THEN\r
+ ELSIF (NEW.create_dt >= DATE '2013-04-01' AND NEW.create_dt < DATE '2013-07-01') THEN\r
INSERT INTO player_weapon_stats_2013Q2 VALUES (NEW.*);\r
ELSE\r
RAISE EXCEPTION 'Date out of range. Fix the player_weapon_stats_ins() trigger!';\r
END;\r
$$\r
LANGUAGE plpgsql;\r
+\r
+DROP TRIGGER IF EXISTS player_weapon_stats_ins_trg ON xonstat.player_weapon_stats;\r
+CREATE TRIGGER player_weapon_stats_ins_trg\r
+ BEFORE INSERT on xonstat.player_weapon_stats\r
+ FOR EACH ROW EXECUTE PROCEDURE player_weapon_stats_ins();\r