<?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 decode(v.bp_count, 0, '1', '0') existsFlag
  from ( select (select count(1)
           from hls_bp_master h, hls_bp_master_signer hb
          where h.social_code = ${@social_code}
            and h.bp_name = ${@bp_name}
            and hb.id_card = ${@agent_id_no}
            and hb.name = ${@agent_name}
            and h.bp_id = hb.bp_id
            and h.enabled_flag = 'Y'
            and h.bp_class = 'ORG') +
       (select count(1)
           from HLS_BP_MASTER t
          where t.enabled_flag = 'Y'
            and t.bp_class = 'ORG'
            and t.bp_type = 'AGENT'
            and t.social_code = ${@social_code}
            and t.bp_name = ${@bp_name}
            and t.id_card_no_ag = ${@agent_id_no}
            and t.bp_name_ag = ${@agent_name}) bp_count from dual) v
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="existsFlag"/>
    </bm:fields>
</bm:model>
