/* All Patches */
SELECT DISTINCT 
       osc.PROD_ID,
	   pkg.pkg_name,
	   pv.pkg_version,
	   pd.IS_REJECTED,
	   pkg.pkg_id,
	   pv.is_patch,
	   pv.pv_id,
	   os.os_name	   
  FROM bom_contents bc, 
   	   operating_systems os, 
       os_contents osc,
	   PACKAGES pkg,
  	   PACKAGE_VERSIONS pv,
	   PRODUCT_DETAILS pd,
	   BRANCHES br,
	   DM_PROJECTS prj,
	   BOMS
 WHERE osc.os_id = os.os_id 
   AND os.node_id = bc.node_id
   AND prj.PROJ_NAME = :PROJ_NAME
   AND br.BRANCH_NAME = :BRANCH_NAME
   AND prj.PROJ_ID = br.PROJ_ID
   and br.BRANCH_ID = boms.BRANCH_ID
   and boms.BOM_ID = bc.BOM_ID
   AND boms.BOM_VERSION = :BOM_VERSION
   AND boms.BOM_LIFECYCLE = :BOM_LIFECYCLE
   AND pd.PROD_ID (+) = osc.PROD_ID
   AND pv.pkg_id = pkg.pkg_id
   AND osc.prod_id = pv.pv_id 
   AND pv.IS_PATCH IS NOT NULL
 ORDER BY UPPER(pkg.pkg_name), UPPER(pv.PKG_VERSION) 
