/* Bom Names List */
SELECT DISTINCT
	   bn.BOM_NAME_ID, 
	   bn.BOM_NAME
  FROM BRANCHES br,
  	   BOMS bo,
	   BOM_NAMES bn
 WHERE bo.BRANCH_ID = br.BRANCH_ID
   AND bo.BOM_NAME_ID = bn.BOM_NAME_ID
   AND (
		 ( br.PROJ_ID = :PROJ_ID	  AND  :PROJ_ID IS NOT NULL) OR
		 ( br.PROJ_ID = br.PROJ_ID     AND  :PROJ_ID IS NULL )
	   )
 ORDER BY UPPER(bn.BOM_NAME)   
       