After loading function to source editor it displayed with error marks and some lines splitted in the middle of the word (see " AS time_id, " on the screenshot). If I trying to compile it in TEE - I getting strange errors and see only part of the function on the SQL Problems window. Even if I will fix such typo (?) mistakes it still can't compile and shows me the same errors (see attachment). P.s. Function itself is correct and was successfully compiled in psql console before. There are no any special or hidden characters. Many of my functions have similar problem(s) (all of them are valid and looks good in ,say, pgadmin utility).. P.p.s Function source: CREATE OR REPLACE FUNCTION one_game_rule(IN p_rule_pk smallint, IN p_start_date timestamp without time zone) RETURNS void AS $BODY$ /******************************************************************************* * * * Version: 1.0.0.0 * * * *******************************************************************************/ DECLARE v_rec RECORD; v_games BIGINT; v_date VARCHAR; BEGIN SELECT CAST(coalesce(value, '0'::VARCHAR) AS BIGINT) INTO v_games FROM rule_attrib WHERE rule_fk = p_rule_pk AND name = 'GAME_COUNT'; SELECT value INTO v_date FROM rule_attrib WHERE rule_fk = p_rule_pk AND name = 'PERIOD'; FOR v_rec IN (SELECT min(time_id) AS time_id, dwh_customer_id AS customer_id, game_code_id, sum(finished_games) AS games FROM dwh_owner.dwh2_fact_business_summary WHERE dwh_customer_id IN (SELECT dwh_customer_id FROM dwh_owner.dwh2_fact_business_summary INNER JOIN get_customers(p_rule_pk) c ON dwh_customer_id = c.customer_id GROUP BY dwh_customer_id HAVING(count(game_code_id) = 1)) GROUP BY dwh_customer_id, game_code_id) LOOP INSERT INTO activity (activity_pk, account_id, merchant_code, activity_date, rule_fk, details) SELECT nextval('activity_seq'), c.account_id, m.code, now(), p_rule_pk, 'Period:' || to_char(current_timestamp - (t.time_full_date::DATE - 1), 'YYYY-MM-DD HH24:MI:SS') || ', Game code:' || g.code || ', Games played:' || v_rec.games::VARCHAR FROM dwh_owner.dwh2_time t, dwh_owner.dwh_game_codes g, dwh_owner.dwh2_customer c, dwh_owner.dwh_merchants m WHERE t.time_id = v_rec.time_id AND g.game_code_pk = v_rec.game_code_id AND c.dwh_customer_id = v_rec.customer_id AND c.merchant_id = m.merchant_pk AND v_rec.games >= v_games AND to_timestamp(extract('epoch' FROM current_timestamp) - coalesce(v_date, '0'::VARCHAR)::double precision) >= t.time_full_date; END LOOP; END; $BODY$ LANGUAGE plpgsql VOLATILE;
↧