-- -- content_type__get_template/2 -- create or replace function content_type__get_template( character varying, character varying ) returns int4 as $$ declare get_template__content_type alias for $1; get_template__use_context alias for $2; v_template_id cr_templates.template_id%TYPE; begin select template_id into v_template_id from cr_type_template_map where content_type = get_template__content_type and use_context = get_template__use_context and is_default = 't'; return v_template_id; end;$$ language plpgsql;