select count(*) from dotlrn_departments_full
where department_key = :dep_id
update dotlrn_departments
set external_url = :external_url
where department_key = :department_key
update dotlrn_community_types
set pretty_name = :pretty_name,
description = :description
where community_type = :department_key
update dotlrn_community_types
set pretty_name = :pretty_name,
description = :description
where community_type = :class_key
select count(*)
from dotlrn_classes
where department_key = :department_key
select count(*)
from dotlrn_community_types
where community_type = :community_type
select count(*)
from dotlrn_classes
where class_key = :class_key
insert into ims_ent_dotlrn_class_map (community_id, class_instance_key)
values (:class_instance_id, :class_instance_key)
select community_id from ims_ent_dotlrn_class_map
where class_instance_key = :class_instance_key
(select term_id
from dotlrn_terms
where start_date >= :start_date
and end_date <= :end_date
order by end_date DESC)
UNION
(select term_id
from dotlrn_terms
where end_date >= now()
order by end_date DESC)
limit 1