<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ZLF  
    $Date: 2015-1-15 下午4:07:02  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from(
            	select c.contract_id,
       c.contract_number,
       c.bp_id_tenant,
       (select h.bp_name from hls_bp_master h where h.bp_id = c.bp_id_tenant) bp_name,
       cli.brand_id,
       (select bv.description
          from hls_car_brands_vl bv
         where bv.brand_id = cli.brand_id) brand_des,
       cli.series_id,
       (select sv.description
          from hls_car_series_vl sv
         where sv.series_id = cli.series_id) series_des,
       cli.model_id,
       (select mv.description
          from hls_car_model_vl mv
         where mv.model_id = cli.model_id) model_des,
       cid.item_frame_number,
       (select a.license_number
          from ast_car_license a
         where a.item_detail_id = cid.item_detail_id
           and a.enabled_flag = 'Y') license_number,
       (select a.mortgage_by
          from ast_car_license a
         where a.item_detail_id = cid.item_detail_id
           and a.enabled_flag = 'Y') mortgage_by,
       (select a.mortgage_date
          from ast_car_license a
         where a.item_detail_id = cid.item_detail_id
           and a.enabled_flag = 'Y') mortgage_date

  from con_contract             c,
       con_contract_lease_item  cli,
       con_contract_item_detail cid
 where c.contract_id = cli.contract_id
   and cli.contract_lease_item_id = cid.contract_lease_item_id
   and c.data_class = 'NORMAL') t1 #WHERE_CLAUSE#
            	
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like ${@contract_number}"/>
        <bm:query-field name="bp_name" queryExpression="t1.bp_name like ${@bp_name}"/>
    </bm:query-fields>
</bm:model>
