DO $$
BEGIN
IF NOT EXISTS(
SELECT schema_name
FROM information_schema.schemata
WHERE schema_name = 'sngm'
)
THEN
EXECUTE 'CREATE SCHEMA sngm';
END IF;
END
$$;
DROP VIEW IF EXISTS sngm.hero_statistics CASCADE;
CREATE OR REPLACE VIEW sngm.hero_statistics AS
SELECT tourney_hand_player_statistics.id_hand,
tourney_hand_player_statistics."position",
tourney_hand_player_statistics.cnt_p_face_limpers,
tourney_hand_player_statistics.flg_vpip,
tourney_hand_player_statistics.flg_p_open_opp,
tourney_hand_player_statistics.flg_p_first_raise,
tourney_hand_player_statistics.flg_p_limp,
tourney_hand_player_statistics.flg_p_3bet,
tourney_hand_player_statistics.flg_p_3bet_opp,
tourney_hand_player_statistics.flg_p_3bet_def_opp,
tourney_hand_player_statistics.flg_blind_def_opp,
tourney_hand_player_statistics.flg_steal_att,
tourney_hand_player_statistics.flg_steal_opp,
tourney_hand_player_statistics.flg_f_cbet,
tourney_hand_player_statistics.flg_f_cbet_opp,
tourney_hand_player_statistics.flg_f_cbet_def_opp,
tourney_hand_player_statistics.flg_t_cbet,
tourney_hand_player_statistics.flg_t_cbet_opp,
tourney_hand_player_statistics.flg_t_cbet_def_opp,
tourney_hand_player_statistics.flg_r_cbet,
tourney_hand_player_statistics.flg_r_cbet_opp,
tourney_hand_player_statistics.flg_r_cbet_def_opp,
tourney_hand_player_statistics.flg_p_fold,
tourney_hand_player_statistics.flg_f_fold,
tourney_hand_player_statistics.flg_t_fold,
tourney_hand_player_statistics.flg_f_bet,
tourney_hand_player_statistics.flg_t_bet,
tourney_hand_player_statistics.flg_r_bet,
tourney_hand_player_statistics.flg_f_open_opp,
tourney_hand_player_statistics.flg_t_open_opp,
tourney_hand_player_statistics.flg_r_open_opp
FROM tourney_hand_player_statistics
WHERE tourney_hand_player_statistics.flg_hero;
ALTER TABLE sngm.hero_statistics
OWNER TO postgres;
DROP FUNCTION IF EXISTS sngm.vshero(integer);
CREATE OR REPLACE FUNCTION sngm.vshero(id_hand integer)
RETURNS sngm.hero_statistics AS
$BODY$
select *
from sngm.hero_statistics
where id_hand = $1
$BODY$
LANGUAGE sql STABLE
COST 100;
ALTER FUNCTION sngm.vshero(integer)
OWNER TO postgres;