<?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
                    *
                FROM
                    (SELECT
					    cccr.change_req_id,
                        cccr.wfl_instance_id,
                        cc.contract_id,
                        cc.contract_number,
                        zj.document_info,
                        cccr.ccr_type,
                        (SELECT
                            v.code_value_name
                        FROM
                            sys_code_values_v v
                        WHERE
                            v.code      ='CON731_CCR_TYPE' AND
                            v.code_value=cccr.ccr_type
                        ) ccr_type_n,
                        cccr.req_date
                    FROM
                        con_contract_change_req cccr,
                        con_contract cc,
                        zj_wfl_workflow_instance_v zj
                    WHERE
                        cc.contract_id         = cccr.contract_id AND
                        cccr.req_status        = 'APPROVED' AND
                        cccr.document_category = 'CHANGE_REQUEST' AND
                        cccr.wfl_instance_id   = zj.instance_id
                    ) tt #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="wfl_instance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WFL_INSTANCE_ID"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER"/>
        <bm:field name="document_info" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_INFO"/>
        <bm:field name="ccr_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CCR_TYPE"/>
        <bm:field name="req_date" databaseType="DATE" datatype="java.util.Date" physicalName="REQ_DATE"/>
        <bm:field name="ccr_type_n"/>
		<bm:field name="change_req_id"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="tt.contract_id=${@contract_id}"/>
    </bm:query-fields>
</bm:model>
