<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="BGFL_PROJECT_TO_CONTRACT_MAIN">
    <bm:fields>
        <bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RECORD_ID" prompt="BGFL_PROJECT_TO_CONTRACT_MAIN.RECORD_ID"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" prompt="BGFL_PROJECT_TO_CONTRACT_MAIN.PROJECT_ID"/>
        <bm:field name="main_contract_sum" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MAIN_CONTRACT_SUM" prompt="BGFL_PROJECT_TO_CONTRACT_MAIN.MAIN_CONTRACT_SUM"/>
        <bm:field name="project_number"/>
        <bm:field name="project_name"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="record_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (select t.record_id,
            t.project_id,pp.project_number,pp.project_name,t.main_contract_sum
             from bgfl_project_to_contract_main t,prj_project pp 
            where pp.project_id=t.project_id(+) ) tt
            #WHERE_CLAUSE#
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
            con_contract_pkg.bgfl_prj_to_con_main_ins(p_project_id =>${@project_id},
                                     p_main_contract_sum =>${@main_contract_sum},
                                     p_user_id        =>${/session/@user_id});
            end;
    		]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    con_contract_pkg.bgfl_prj_to_con_main_update(p_project_id =>${@project_id},
                     				p_main_contract_sum =>${@main_contract_sum}, 
                     				p_user_id =>${/session/@user_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="tt.project_id=${/parameter/@project_id}"/>
    </bm:data-filters>
</bm:model>
