SELECT *
  FROM	(

		/* ------- ERROR: Unofficial dependencies found ------- */
		SELECT DISTINCT 'enum_MSG_UNOFFICIAL_DEPENDENCIES_FOUND' AS err_message,
			   'dependencies.asp' AS rfile,
		       '' AS anchor,
               3 AS priority,
			   'ERROR' AS products_msg
		  FROM PACKAGE_DEPENDENCIES dep,
		       PACKAGE_VERSIONS dpv
		 WHERE dep.dpv_id = dpv.pv_id
		   AND dep.pv_id = :PV_ID
		   AND dpv.dlocked = 'N'

		UNION

		/* ------- ERROR: Package Information Section Incomplete ------- */
		SELECT DISTINCT 'enum_MSG_PACKAGE_INFORMATION_INCOMPLETE' AS err_message,
			   'fixed_issues.asp' AS rfile,
		       '#PACKAGE_INFORMATION' AS anchor,
               10 AS priority,
			   'ERROR' AS products_msg
		  FROM PACKAGE_VERSIONS pv
		 WHERE pv.pv_id = :PV_ID
         AND (     pv.PV_DESCRIPTION IS NULL
		   		 OR pv.PV_OVERVIEW IS NULL
				 OR pv.IS_BUILD_ENV_REQUIRED IS NULL
		       )

		UNION

		/* ------- ERROR: Version Control Info ------- */
		SELECT DISTINCT 'enum_MSG_VCS_INFORMATION_INCOMPLETE' AS err_message,
			   'fixed_issues.asp' AS rfile,
		       '#PACKAGE_INFORMATION' AS anchor,
               11 AS priority,
			   'ERROR' AS products_msg
         FROM  PACKAGE_VERSIONS pv,
               VCS_TYPE vt
		 WHERE pv.pv_id = :PV_ID
           AND pv.vcs_type_id  = vt.vcs_type_id
		   AND ( (vt.tag = 'SVN' OR vt.tag = 'CC' or vt.tag = 'CVS')
				   AND (    pv.PKG_LABEL IS NULL
		                 OR pv.SRC_PATH IS NULL
						)
				)
		UNION

      /* ------- ERROR: Package Information Section - Autobuild with VCS Uncontrolled ------- */
      SELECT DISTINCT 'enum_MSG_AUTOBUILD_PACKAGE_IS_UNCONTROLLED' AS err_message,
             'fixed_issues.asp' AS rfile,
             '#PACKAGE_INFORMATION' AS anchor,
             12 AS priority,
             'ERROR' AS products_msg
        FROM PACKAGE_VERSIONS pv
       WHERE pv.pv_id = :PV_ID
         AND pv.build_type = 'A'
         AND pv.vcs_type_id IN (SELECT vt.vcs_type_id FROM vcs_type vt WHERE vt.tag = 'UC')

		UNION

     	/* ------- ERROR: Reason For This Version ------- */
        SELECT DECODE( pv.COMMENTS,
        			   NULL, DECODE( fixedcq.cnt, 0, 'enum_MSG_REASON_FOR_THIS_VERSION_NOT_SUPLIED', NULL ), NULL ) AS err_message,
               'fixed_issues.asp' AS rfile,
		       '#REASON_FOR_THIS_RELEASE' AS anchor,
               13 AS priority,
			   'ERROR' AS products_msg
		  FROM (
		        SELECT COUNT(*) AS cnt
		          FROM CQ_ISSUES cqi
		         WHERE cqi.pv_id = :PV_ID
		           AND iss_state = :enumISSUES_STATE_FIXED
          		) fixedcq,
                PACKAGE_VERSIONS pv
		 WHERE pv.pv_id = :PV_ID

		UNION

		/* ------- ERROR: Unit Test Section Incompete ------- */
		SELECT DECODE( COUNT(*), 0, 'enum_MSG_UNIT_TESTS_NOT_SUPPLIED', NULL ) AS err_message,
			   'fixed_issues.asp' AS rfile,
		       '#UNIT_TESTS' AS anchor,
               14 AS priority,
			   'ERROR' AS products_msg
		  FROM UNIT_TESTS ut
		 WHERE ut.PV_ID = :PV_ID

		) errmsg
ORDER BY priority
