-- FUNCTION: sonex.current_account_preferences_get()

-- DROP FUNCTION IF EXISTS sonex.current_account_preferences_get();

CREATE OR REPLACE FUNCTION sonex.current_account_preferences_get(
	)
    RETURNS TABLE(key text, value text) 
    LANGUAGE 'sql'
    COST 100
    STABLE SECURITY DEFINER PARALLEL UNSAFE
    ROWS 1000

AS $BODY$
    SELECT ap."key", ap."value"
    FROM sonex.account_preferences ap
    WHERE ap.account_name = session_user
    ORDER BY ap."key";
$BODY$;

ALTER FUNCTION sonex.current_account_preferences_get()
    OWNER TO postgres;

GRANT EXECUTE ON FUNCTION sonex.current_account_preferences_get() TO PUBLIC;

GRANT EXECUTE ON FUNCTION sonex.current_account_preferences_get() TO account;

GRANT EXECUTE ON FUNCTION sonex.current_account_preferences_get() TO postgres;

