select count(option_id) as id_valid_p
from ttracker_options
where option_id = :value and
package_id = :package_id
select count(wt.task_id) as id_valid_p
from wf_tasks wt
where exists (select wc.case_id
from wf_cases wc,
ttracker_tickets tt,
ttracker_categories tc
where wt.case_id = wc.case_id
and wc.object_id = tt.ticket_id
and tt.category_id = tc.category_id
and tc.package_id = :package_id)
and wt.task_id = :value
select case when count(1) = 0 then 0 else 1 end
from ttracker_categories
where package_id = :package_id