Connects with conf table, implements helper and adds tests

This commit is contained in:
Guido Fioravantti
2015-11-10 15:31:53 +01:00
parent 47ff4d4d44
commit aabc873eac
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
-- Get values_json for provided key from conf table
CREATE OR REPLACE FUNCTION _get_conf(_key TEXT)
RETURNS text
AS $$
DECLARE
rec RECORD;
BEGIN
SELECT INTO rec values_json FROM conf WHERE conf.key = _key;
IF NOT FOUND THEN
RAISE EXCEPTION 'Missing key ''%'' in conf table', _key;
END IF;
RETURN rec.values_json;
END
$$ LANGUAGE plpgsql;