<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
               begin
                hls_bp_master_credit_pkg.check_create_record(
                                  p_bp_credit_hd_id   =>${@bp_credit_hd_id}
                                );
                end;]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (select rd.bp_credit_hd_id,
       rd.bp_id,
       hbm.bp_name,
       hbm.bp_code,
       hbm.bp_category,
       (select description
          from hls_bp_category hbc
         where hbc.bp_category = hbm.bp_category) bp_category_n,
       hbm.bp_name bp_id_n,
       rd.credit_total_amount,

       rd.credit_type,
       (select v.code_value_name
          from sys_code_values_v v
         where v.code = 'DS_CREDIT_TYPE'
           and v.code_value = rd.credit_type) credit_type_n,
       to_char(rd.credit_date_from,'yyyy-mm-dd')credit_date_from,
       rd.credit_status,
       (select code_value_name
          from sys_code_values_v
         where code = 'CREDIT_STATUS'
           and code_value = rd.credit_status) credit_status_n,
       to_char(rd.credit_date_to,'yyyy-mm-dd')credit_date_to,
       rd.enable_flag,
       to_char(rd.last_update_date,'yyyy-mm-dd')last_update_date,
       (select description from sys_user s where s.user_id= rd.created_by)last_updated_by_desc,
       (select description from sys_user s where s.user_id= rd.temp_user)temp_user_desc

  from HLS_BP_MASTER_CREDIT_HD  hd,
       hls_bp_master            hbm,
       hls_bp_mast_credit_hd_rd rd
 where hd.bp_id = hbm.bp_id
   and hd.bp_credit_hd_id = rd.bp_credit_hd_id)v
                #WHERE_CLAUSE#
                ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter name="query" expression="bp_credit_hd_id=${@bp_credit_hd_id}"/>
    </bm:data-filters>
</bm:model>