postgresql7.2 select w.workflow_id, w.short_name, w.pretty_name, w.object_id, w.package_key, w.object_type, w.description, w.description_mime_type, a.short_name as initial_action, a.action_id as initial_action_id from workflows w left outer join workflow_actions a on (a.workflow_id = w.workflow_id and a.parent_action_id is null and a.trigger_type = 'init') where w.workflow_id = :workflow_id select workflow__new ( :attr_short_name, :attr_pretty_name, :attr_package_key, :attr_object_id, :attr_object_type, :attr_creation_user, :attr_creation_ip, :attr_context_id ); select workflow__delete(:workflow_id); select coalesce(max(sort_order),0) + 1 from workflow_callbacks where workflow_id = :workflow_id