SELECT st.short_text INTO l_short_text
FROM fnd_attachment_functions fndattfn,
fnd_doc_category_usages fndcatusg,
fnd_documents_vl fnddoc,
fnd_attached_documents fndattdoc,
fnd_documents_short_text st,
fnd_document_categories_tl fdtl
--fnd_attached_docs_form_vl fadf
WHERE fndattfn.attachment_function_id = fndcatusg.attachment_function_id
AND fndcatusg.category_id = fnddoc.category_id
AND fnddoc.document_id = fndattdoc.document_id
AND fndattfn.function_name = 'OEXOETEL'
--AND fndattdoc.entity_name = 'OE_ORDER_HEADERS'
AND fnddoc.media_id = st.media_id(+)
AND fdtl.category_id = fndcatusg.category_id
--AND fdtl.user_name IN ('Sales Order Acknowledgement - Header')
AND fdtl.user_name = :P_FOOTER_ATTACH
AND fndattdoc.pk1_value = :OE_ORDER_HEADERS_ALL.HEADER_ID
/*AND fadf.pk1_value = fndattdoc.pk1_value
AND fndattfn.function_name = fadf.function_name
AND fadf.document_id = fnddoc.document_id
AND fndcatusg.format = 'F'
AND fadf.function_type = 'R'*/
AND fdtl.LANGUAGE = USERENV ('LANG');
*****************************************************************
Below query is Tuned
*****************************************************************
select
-- pk1_value ftr_header_id,
pk1_value actheadnote_id,
fdst.short_text actheadnote,
fdlt.long_text actheadnote_long,
fdc.user_name ftr_headuse_ord,
TO_NUMBER ( fdc.attribute1 ) ftr_headuseseq_ord,
datatype_id ftr_note_datatype_id,
fd.datatype_id actheadnote_datatype_id
from fnd_attachment_functions faf,
fnd_document_categories_vl fdc,
fnd_doc_category_usages fdcu,
fnd_documents_vl fd,
fnd_attached_documents fad,
fnd_documents_long_text fdlt,
fnd_documents_short_text fdst
where faf.attachment_function_id = fdcu.attachment_function_id
and fdcu.category_id = fd.category_id
and fdc.category_id = fd.category_id
and fd.document_id = fad.document_id
and faf.function_name = :P_FUNCTION_NAME
--and faf.function_name = 'OEXOEORD'
and fad.entity_name = 'OE_ORDER_HEADERS'
and fd.datatype_id in (1,2)
and fd.media_id=fdst.media_id(+)
and fd.media_id=fdlt.media_id(+)
and fdc.user_name <> 'AU Header Comments' ---- to hide attachments URL from XMl reports
and fdc.user_name <> 'Internal'
and faf.function_type='R'
AND FDCU.format = 'F'
order by seq_num
No comments:
Post a Comment