Ibatis 分页SqL的实例

<select id="getZhAllCheckerConfigList" parameterClass="java.util.HashMap"
		resultClass="java.util.HashMap" remapResults="true">
		<![CDATA[
		select bb.* from (
		    select aa.*, rownum RR from  ( 
		     select
		     distinct
		      t.APPLYFORM_ID ,
		      t.CONTRACT_NO ,
		      t.PO_NO ,
		      i.productline_id,
		      (select e.item_name from sup_dict_item e where e.item_id = i.productline_id  and e.nls_lang = #nls#) as PRODUCT_LINE_NAME,
		      s.product_family as product_family,
		      (select e.item_name from sup_dict_item e where e.item_id = s.product_family  and e.nls_lang = #nls#) as PRODUCT_FAMILY_NAME,
		      s.product,
		      s.pp_product,
		      i.po_product_name,
		      i.po_version, 
		      t.CUSTOMER_ID,
		      (select c.Namechn from sup_ent_company c where c.companyid=t.CUSTOMER_ID and rownum=1) as CUSTOMER,
		      t.APPLICANT_REGION_ID,
		      (select v.sChnDeptName  from sup_v_tsd_region v where  v.iDeptID=t.APPLICANT_REGION_ID and rownum=1) as APPLICANT_REGION ,
      		  t.APPLICANT_OFFICE_ID,
      		  (select v.schndeptname  from sup_v_tsd_region v  where v.iDeptID=t.APPLICANT_OFFICE_ID and rownum=1)as APPLICANT_OFFICE,
		      t.APPLYFORM_STATUS ,
		      (select d.item_name  from sup_dict_item d where d.item_id = t.APPLYFORM_STATUS and d.nls_lang = #nls# ) as STATUS_NAME,
		      t.TIME_ON_PLAN,
		      t.GRANT2TIME,
		      t.AUDITER ,
		      to_char(t.APPLY_TIME,'yyyy-mm-dd') APPLY_TIME,
		      t.CREATOR,
		      t.APPLICANT_ACCOUNT, 
		      t.applyform_name,
		      to_char(t.LAST_MODIFIED_TIME,'yyyy-mm-dd') LAST_MODIFIED_TIME 
		        from sup_po_apply_form t 
		        inner join sup_po_sw_info i on t.CONTRACT_NO = i.CONTRACT_NO  and t.pp_product = i.pp_product
		    inner join sup_sc_family_info s on i.pp_product = s.pp_product
		    where 1=1 
		]]>
		<dynamic>
			<isNotEmpty property="APPLYFORM_STATUS" prepend="AND">
				t.APPLYFORM_STATUS in ($APPLYFORM_STATUS$) 
			</isNotEmpty>
			<isNotEmpty property="APPLY_TIME" prepend="AND">
				TO_CHAR(t.APPLY_TIME, 'yyyy-mm-dd') = #APPLY_TIME#
			</isNotEmpty>
			<isNotEmpty property="CONTRACT_NO" prepend="AND">
				Upper(t.CONTRACT_NO) like Upper('%'||#CONTRACT_NO#||'%')
			</isNotEmpty>
			<isNotEmpty property="PO_NO" prepend="AND">
				Upper(t.PO_NO) like Upper('%'||#PO_NO#||'%') 
			</isNotEmpty>
			<isNotEmpty property="APPLYFORM_ID" prepend="AND">
				Upper(t.APPLYFORM_ID) like Upper('%'||#APPLYFORM_ID#||'%')
			</isNotEmpty>
			<isNotEmpty property="APPLICANT_ACCOUNT" prepend="AND">
				Upper(t.APPLICANT_ACCOUNT) like Upper('%'||#APPLICANT_ACCOUNT#||'%')
			</isNotEmpty>
			<isNotEmpty property="AUDITER" prepend="AND">
				Upper(t.AUDITER) like Upper('%'||#AUDITER#||'%')
			</isNotEmpty>
			<isNotEmpty property="CREATOR" prepend="AND">
				Upper(t.CREATOR) like Upper('%'||#CREATOR#||'%')
			</isNotEmpty>
			<isNotEmpty property="productline_id" prepend="AND">
				i.productline_id = #productline_id#
			</isNotEmpty>
			<isNotEmpty property="product_family" prepend="AND">
				s.product_family = #product_family#
			</isNotEmpty>
			<isNotEmpty property="product" prepend="AND">
				s.product = #product#
			</isNotEmpty>
	    <![CDATA[
		    ) aa where rownum <=  #ROWNUM_HIGH#
			) bb  where bb.RR >= #ROWNUM_LOW# 
         ]]>
		</dynamic>
	</select>

你可能感兴趣的:(分页)