postgresql7.3
SELECT
i.item_id
FROM
cr_items i,
cr_revisions r
WHERE
i.item_id = r.item_id and
r.revision_id = :task_id
SELECT
live_revision
FROM
cr_items i
WHERE
i.item_id = :task_item_id
select status
from pm_tasks
where task_id = :task_item_id
SELECT
case when status_type = 'c' then 0 else 1 end as open_p
FROM
pm_tasks t,
pm_task_status s
WHERE
task_id = :task_item_id and
t.status = s.status_id
select status_id
from pm_task_status
where status_type = 'o'
limit 1
select status_id
from pm_task_status
where status_type = 'c'
limit 1
obviously broken
select package_id from surveys
where survey_id=:object_id
SELECT
r.item_id,
r.title as task_title
FROM
pm_tasks_revisionsx r,
cr_items i,
pm_tasks t,
pm_task_status s
WHERE
r.parent_id = :project_item_id and
r.revision_id = i.live_revision and
i.item_id = t.task_id and
t.status = s.status_id and
s.status_type = 'o'
$union_clause
ORDER BY
task_title
select pm_task__new_task_revision (
:task_item_id,
:project_item_id,
:title,
:description,
:mime_type,
[pm::util::datenvl -value $end_date -value_if_null "null" -value_if_not_null "to_timestamp('$end_date','YYYY MM DD HH24 MI SS')"],
:percent_complete,
:estimated_hours_work,
:estimated_hours_work_min,
:estimated_hours_work_max,
:actual_hours_worked,
:status_id,
current_timestamp,
:update_user,
:update_ip,
:package_id)
select pm_task__new_task_item (
:project_id,
:title,
:description,
:mime_type,
[pm::util::datenvl -value $end_date -value_if_null "null" -value_if_not_null "to_timestamp('$end_date','YYYY MM DD HH24 MI SS')"],
:percent_complete,
:estimated_hours_work,
:estimated_hours_work_min,
:estimated_hours_work_max,
:status_id,
coalesce (:creation_date,current_timestamp),
:creation_user,
:creation_ip,
:package_id)