Monday, 23 June 2014

Query to find attachments of a contract

SELECT adoc.creation_date creation_date,
       docs.last_update_date,
       docs.document_id,
       adoc.attached_document_id,
       docs.category_id,
       DECODE (docs.datatype_id, 1, docs_tl.media_id, NULL) text_id,
       docs.datatype_id,
       adoc.pk1_value contract_number,
       docs_tl.doc_attribute2 file_size,
       adoc.automatically_added_flag,
       adoc.created_by,
       DECODE (docs.datatype_id, 5, docs_tl.file_name, NULL) link_url,
       docs_tl.language,
       DECODE (docs.datatype_id, 6, docs_tl.file_name, NULL) file_name,
       docs_tl.description,
       doc_s_text.short_text,
       DECODE (docs.datatype_id, 6, docs_tl.media_id, NULL) fileid,
       docs.publish_flag,
       docs_tl.file_name
FROM fnd_attached_documents adoc,
     fnd_documents docs,
     fnd_documents_tl docs_tl,
     fnd_documents_short_text doc_s_text
WHERE     1 = 1
      AND adoc.document_id = docs.document_id
      AND docs.document_id = docs_tl.document_id
      AND docs_tl.language = USERENV (‘lang’)
      AND docs_tl.media_id = doc_s_text.media_id(+)
      AND adoc.entity_name = 'OKC_K_HEADERS_V'
      AND pk1_value = '1081665'            -- Enter your contract number here.

1 comment: