<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_AGENT_DIVISION">
    <bm:fields>
        <bm:field name="agent_division_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="AGENT_DIVISION_ID" prompt="HLS_AGENT_DIVISION.AGENT_DIVISION_ID"/>
        <bm:field name="division_detail_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DIVISION_DETAIL_ID" prompt="HLS_AGENT_DIVISION.DIVISION_DETAIL_ID"/>
        <bm:field name="division_detail_code" forInsert="false" forUpdate="false" prompt="产品线细分编码"/>
        <bm:field name="agent_bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="AGENT_BP_ID" prompt="HLS_AGENT_DIVISION.AGENT_BP_ID"/>
        <bm:field name="agent_bp_code" databaseType="VARCHAR" datatype="java.lang.String" physicalName="AGENT_BP_CODE" prompt="HLS_AGENT_DIVISION.AGENT_BP_CODE"/>
        <bm:field name="agent_bp_name" databaseType="VARCHAR" datatype="java.lang.String" physicalName="AGENT_BP_NAME" prompt="HLS_AGENT_DIVISION.AGENT_BP_NAME"/>
        <bm:field name="enable_flag" databaseType="VARCHAR" datatype="java.lang.String" physicalName="ENABLE_FLAG" prompt="启用"/>
        </bm:fields>
        <bm:operations>
              <bm:operation name="query">
                  <bm:query-sql><![CDATA[
                      SELECT t1.agent_division_id,
                             t1.division_detail_id,
                             (SELECT d.division_detail_code
                                FROM hls_division_detail d
                               WHERE d.division_detail_id = t1.division_detail_id) division_detail_code,
                             t1.agent_bp_id,
                             t1.agent_bp_code,
                             t1.agent_bp_name,
                             t1.enable_flag,
                             t1.creation_date,
                             t1.created_by,
                             t1.last_update_date,
                             t1.last_updated_by
                        FROM HLS_AGENT_DIVISION t1 #WHERE_CLAUSE#
                  ]]></bm:query-sql>
              </bm:operation>
              <bm:operation name="insert">
                  <bm:parameters>
                      <bm:parameter name="agent_division_id" input="false" output="true" outputPath="@agent_division_id"/>
                  </bm:parameters>
                  <bm:update-sql><![CDATA[
              		begin

      				  HLS103_SAVE_PKG.hls_agent_division_manage(p_sql_type		 => 'INSERT',
      				  							  p_agent_division_id   => ${@agent_division_id},
      								              p_division_detail_id          => ${@division_detail_id},
      								              p_agent_bp_id      => ${@agent_bp_id},
      								              p_agent_bp_code => ${@agent_bp_code},
      								              p_agent_bp_name	 => ${@agent_bp_name},
      								              p_enable_flag    => ${@enable_flag},
      								              p_user_id          => ${/session/@user_id});

      				end;
              	]]></bm:update-sql>
              </bm:operation>
              <bm:operation name="update">
                  <bm:update-sql><![CDATA[
              		begin

      				  HLS103_SAVE_PKG.hls_agent_division_manage(p_sql_type		 => 'UPDATE',
      				  							  p_agent_division_id   => ${@agent_division_id},
                                                  p_division_detail_id  => ${@division_detail_id},
                                                  p_agent_bp_id      => ${@agent_bp_id},
                                                  p_agent_bp_code => ${@agent_bp_code},
                                                  p_agent_bp_name	 => ${@agent_bp_name},
                                                  p_enable_flag    => ${@enable_flag},
                                                  p_user_id          => ${/session/@user_id});

      				end;
              	]]></bm:update-sql>
              </bm:operation>
              <bm:operation name="delete">
                  <bm:update-sql><![CDATA[
              		begin

      				  HLS103_SAVE_PKG.hls_agent_division_manage(p_sql_type		 => 'DELETE',
      				  							p_agent_division_id   => ${@agent_division_id},
                                                p_division_detail_id  => ${@division_detail_id},
                                                p_agent_bp_id      => ${@agent_bp_id},
                                                p_agent_bp_code => ${@agent_bp_code},
                                                p_agent_bp_name	 => ${@agent_bp_name},
                                                p_enable_flag    => ${@enable_flag},
                                                p_user_id          => ${/session/@user_id});


      				end;
              	]]></bm:update-sql>
              </bm:operation>
          </bm:operations>
          <bm:data-filters>
              <bm:data-filter enforceOperations="query" expression="t1.division_detail_id=${@division_detail_id}"/>
          </bm:data-filters>
    <bm:features>
        <f:standard-who/>
        <!--<o:sequence-pk sequenceName="HLS_AGENT_DIVISION_S"/>-->
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="agent_division_id"/>
    </bm:primary-key>
   </bm:model>
