/* Bom Tree Combo */
SELECT bo.BOM_ID,
	   bo.BOM_VERSION ||'.'|| bo.BOM_LIFECYCLE AS BOM_VERSION,
	   DECODE( bo.BOM_ID,
	   		   :COMPARE_BOM_ID, 'selected',
			   NULL ) AS SELECTED
  FROM ( 
		SELECT bo.BOM_ID, bo.BOM_VERSION ||'.'|| bo.BOM_LIFECYCLE AS VERSION
		  FROM BOMS bo
		 WHERE bo.BOM_VERSION = :BOM_VERSION
		   AND bo.BOM_NAME_ID = :BOM_NAME_ID
		   AND bo.BRANCH_ID = :BRANCH_ID 
		UNION 
		SELECT bo.BOM_ID, bo.BOM_VERSION ||'.'|| bo.BOM_LIFECYCLE AS VERSION
		  FROM BOMS bo
		 WHERE bo.BOM_VERSION LIKE :LIKE_BOM_VERSION
		   AND bo.BOM_NAME_ID = :BOM_NAME_ID
		   AND bo.BRANCH_ID = :BRANCH_ID 
	  ) qry,
	  BOMS bo
 WHERE qry.BOM_ID = bo.BOM_ID	  
ORDER BY qry.VERSION, qry.BOM_ID