<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
             SELECT
                    *
                FROM
                    (SELECT
                        A.*,
                        ROWNUM RN
                    FROM
                        (SELECT
                            *
                        FROM
                            (
               select ba.bank_account_name,
               ba.bank_account_id,
               ba.bp_id,
               ba.bank_account_num,
               ba.bank_full_name,
               ba.bank_branch_name,
               ba.deducted_card,
               
               ( select v.code_value code
          from sys_code_values_v v
         where v.code = 'BANK_ACCOUNT_TYPE_NEW'
           and v.code_enabled_flag = 'Y'
           and v.code_value_enabled_flag = 'Y'
           and v.code_value_name = ba.bank_account_type_n) bank_account_type,
               
                (select 
                v.code_value_name code_name
				  from sys_code_values_v v
				 where v.code = 'YES_NO'
				   and v.code_enabled_flag = 'Y'
				   and v.code_value_enabled_flag = 'Y'
				   and v.code_value =  ba.deducted_card) deducted_card_n,
               
               ba.bank_account_type_n,
               to_char(ba.start_date,'yyyy-mm-dd') start_date,
               to_char(ba.expiry_date,'yyyy-mm-dd') end_date
          from hls_bp_master_bank_account_lv ba) t #WHERE_CLAUSE#
                        ORDER BY
                            t.bank_account_id DESC
                        )A
                    WHERE
                        ROWNUM <= NVL(${@pagesize},10) * NVL(${@offsize},1)
                    )
                WHERE
                    RN >= 1 + ((NVL(${@offsize},1)-1) * NVL(${@pagesize},10))

            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="bank_account_name"/>
        <bm:field name="bank_account_id"/>
        <bm:field name="bp_id"/>
        <bm:field name="bank_account_num"/>
        <bm:field name="bank_full_name"/>
        <bm:field name="bank_branch_name"/>
        <bm:field name="deducted_card"/>
        <bm:field name="deducted_card_n"/>
        <bm:field name="bank_account_type"/>
        <bm:field name="bank_account_type_n"/>
        <bm:field name="start_date"/>
        <bm:field name="end_date"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="bp_id" queryExpression="t.bp_id=${@bp_id}"/>
    </bm:query-fields>
</bm:model>
