<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" allowFetchAll="true" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[select fam.table_name,
             fam.table_pk_value,
             fam.record_id,
             faa.attachment_id,
             faa.file_name,
             faa.file_path,
              cdd.description,
               pp.project_number
  from prj_cdd_item_doc_ref     doc,
       fnd_atm_attachment_multi fam,
       fnd_atm_attachment       faa,
        prj_cdd_item_check   ck,
       prj_cdd_item        cdd,
       prj_project         pp
 where doc.document_id = ${@document_id}
   and doc.document_table = ${@document_table}
   and fam.table_name = 'PRJ_CDD_ITEM_CHECK'
   and fam.table_pk_value = doc.check_id
   and doc.check_id =nvl( ${@check_id},doc.check_id)
   and fam.attachment_id = faa.attachment_id
   and ck.check_id=doc.check_id
   and cdd.cdd_item_id=ck.cdd_item_id
    and pp.project_id=doc.document_id]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="document_id"/>
                <bm:parameter name="document_table"/>
                <bm:parameter name="check_id"/>
            </bm:parameters>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="table_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TABLE_NAME" required="true"/>
        <bm:field name="table_pk_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TABLE_PK_VALUE" required="true"/>
        <bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RECORD_ID" required="true"/>
        <bm:field name="attachment_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ATTACHMENT_ID" required="true"/>
        <bm:field name="file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_NAME"/>
        <bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION"/>
        <bm:field name="project_number"/>
    </bm:fields>
</bm:model>
