Thursday, September 6, 2012

Query to check the workflow assigned to an order type

Query to check the workflow assigned to an order type


  SELECT ot.order_type_id,
         ot.name order_type_name,
         ot.description,
         ot.start_date_active,

         ot.end_date_active,
         ot.order_category_code,
         olt1.name default_inbound_line_type,
         olt2.name default_outbound_line_type,
         wf.display_name order_workflow
    FROM wf_activities_vl wf,
         oe_workflow_assignments OWA,
         oe_order_types_v ot,
         oe_line_types_v olt1,
         oe_line_types_v olt2
   WHERE     ot.default_inbound_line_type_id = olt1.line_type_id(+)
         AND ot.default_outbound_line_type_id = olt2.line_type_id(+)
         AND OWA.order_type_id = ot.transaction_type_id
         AND OWA.line_type_id IS NULL
         AND wf.name = OWA.process_name
         AND wf.item_type = 'OEOH'
         AND wf.version =
                (SELECT MAX (version)
                   FROM wf_activities_vl wf1
                  WHERE wf1.name = wf.name AND wf1.item_type = 'OEOH')
         AND TRUNC (SYSDATE) <= NVL (OWA.end_date_active, SYSDATE)
ORDER BY ot.name;