select case when count(*) = 0 then 0 else 1 end
from apm_package_db_types
insert into apm_package_db_types
(db_type_key, pretty_db_name)
values
(:db_type, :db_pretty_name)
select t.package_key
from apm_package_types t
left join apm_packages p
using (package_key)
where p.package_id is null
select package_id
from apm_packages
where instance_name = 'Main Site'