--
-- content_item__unregister_template/3
--
create or replace function content_item__unregister_template(
integer,
integer,
character varying
) returns int4 as $$
declare
unregister_template__item_id alias for $1;
unregister_template__template_id alias for $2; -- default null
unregister_template__use_context alias for $3; -- default null
begin
if unregister_template__use_context is null and
unregister_template__template_id is null then
delete from cr_item_template_map
where item_id = unregister_template__item_id;
else if unregister_template__use_context is null then
delete from cr_item_template_map
where template_id = unregister_template__template_id
and item_id = unregister_template__item_id;
else if unregister_template__template_id is null then
delete from cr_item_template_map
where item_id = unregister_template__item_id
and use_context = unregister_template__use_context;
else
delete from cr_item_template_map
where template_id = unregister_template__template_id
and item_id = unregister_template__item_id
and use_context = unregister_template__use_context;
end if; end if; end if;
return 0;
end;$$ language plpgsql;