<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CON_COLLECTION_CALLBACK_TEMP">
    <bm:fields>
        <bm:field name="callback_temp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALLBACK_TEMP_ID" prompt="CON_COLLECTION_CALLBACK_TEMP.CALLBACK_TEMP_ID"/>
        <bm:field name="contract_lease_item_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_LEASE_ITEM_ID" prompt="CON_COLLECTION_CALLBACK_TEMP.CONTRACT_LEASE_ITEM_ID"/>
        <bm:field name="batch_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BATCH_ID" prompt="CON_COLLECTION_CALLBACK_TEMP.BATCH_ID"/>
        <bm:field name="callback_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALLBACK_ID" prompt="CON_COLLECTION_CALLBACK_TEMP.CALLBACK_ID"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
                DECLARE
                    v_callback_temp_id NUMBER;
                BEGIN
                    SELECT
                        con_collection_callback_temp_s.nextval
                    INTO
                        v_callback_temp_id
                    FROM
                        dual;
                    INSERT
                    INTO
                        CON_COLLECTION_CALLBACK_TEMP
                        (
                            callback_temp_id,
                            contract_lease_item_id,
                            batch_id,
                            callback_id,
                            creation_date,
                            created_by,
                            last_update_date,
                            last_updated_by
                        )
                        VALUES
                        (
                            v_callback_temp_id,
                            ${@contract_lease_item_id},
                            ${@batch_id},
                            ${@callback_id},
                            sysdate,
                            ${/session/@user_id},
                            sysdate,
                            ${/session/@user_id}
                        );
                        
                        UPDATE
                        con_collection_callback
                    SET
                        batch_id = ${@batch_id}
                    WHERE
                        callback_id = ${@callback_id};
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>