select calendar_name, calendar_id, acs_permission__permission_p(calendar_id, :user_id, 'calendar_admin') as calendar_admin_p from calendars
where package_id= :package_id
and (private_p='f' or (private_p='t' and owner_id= :user_id))
select type, item_type_id from cal_item_types
where calendar_id= :calendar_id
insert into cal_item_types
(item_type_id, calendar_id, type)
values
(:item_type_id, :calendar_id, :type)
update cal_items
set item_type_id= NULL
where item_type_id = :item_type_id
and on_which_calendar= :calendar_id
delete from cal_item_types where item_type_id= :item_type_id
and calendar_id= :calendar_id
update calendars
set calendar_name = :name
where calendar_id = :calendar_id