--
-- apm__get_value/2
--
create or replace function apm__get_value(
  get_value__package_id integer,
  get_value__parameter_name character varying
) returns varchar as $$

DECLARE
  v_parameter_id                    apm_parameter_values.parameter_id%TYPE;
  value                             apm_parameter_values.attr_value%TYPE;
BEGIN
    v_parameter_id := apm__id_for_name (get_value__package_id, get_value__parameter_name);

    select attr_value into value from apm_parameter_values v
    where v.package_id = get_value__package_id
    and parameter_id = v_parameter_id;

    return value;
   
END;
$$ language plpgsql;


--
-- apm__get_value/2
--
create or replace function apm__get_value(
  get_value__package_key character varying,
  get_value__parameter_name character varying
) returns varchar as $$

DECLARE
  v_parameter_id                    apm_parameter_values.parameter_id%TYPE;
  value                             apm_parameter_values.attr_value%TYPE;
BEGIN
    v_parameter_id := apm__id_for_name (get_value__package_key, get_value__parameter_name);

    select attr_value into value from apm_parameter_values v
    where v.package_id is null
    and parameter_id = v_parameter_id;

    return value;
   
END;
$$ language plpgsql;