<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="BGFL_EXTERNAL_DEBT_QUOTA_LN">
    <bm:fields>
        <bm:field name="ln_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LN_ID" prompt="BGFL_EXTERNAL_DEBT_QUOTA_LN.LN_ID"/>
        <bm:field name="hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_ID" prompt="BGFL_EXTERNAL_DEBT_QUOTA_LN.HD_ID"/>
        <bm:field name="direction" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DIRECTION" prompt="BGFL_EXTERNAL_DEBT_QUOTA_LN.DIRECTION"/>
        <bm:field name="direction_desc" expression="(select scv.code_value_name from sys_codes_vl sc, sys_code_values_vl scv where sc.code_id = scv.code_id and sc.code=&apos;EXTERNAL_DEBT_QUOTA_DIRECTION&apos; and scv.code_value=t1.direction)"/>
        <bm:field name="quota" databaseType="NUMBER" datatype="java.lang.Long" physicalName="QUOTA" prompt="BGFL_EXTERNAL_DEBT_QUOTA_LN.QUOTA"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="BGFL_EXTERNAL_DEBT_QUOTA_LN.DESCRIPTION"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" prompt="BGFL_EXTERNAL_DEBT_QUOTA_LN.PROJECT_ID"/>
        <bm:field name="project_number" expression="(select pp.project_number from prj_project pp where pp.project_id=t1.project_id)"/>
        <bm:field name="project_name" expression="(select pp.project_name from prj_project pp where pp.project_id=t1.project_id)"/>
        <bm:field name="creation_date"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
    			begin
    				bgfl_external_debt_quota_pkg.external_debt_quota_ln_insert(p_hd_id       =>${@hd_id},
                                          									   p_direction   =>${@direction},
                                                                               p_quota       =>${@quota},
                                          									   p_project_id  =>${@project_id},
                                          									   p_description =>${@description},
                                          									   p_user_id     =>${/session/@user_id});
    			end;
    		]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="hd_id = ${@hd_id}"/>
    </bm:data-filters>
</bm:model>
