XX_ATTACHMENT_FORM_LINKAGE_V
CREATE OR REPLACE VIEW XX_ATTACHMENT_FORM_LINKAGE_V
(
  APPLICATION_NAME
, FUNCTION_TYPE
, FORM_NAME
, USER_FORM_NAME
, DATA_OBJECT_CODE
) AS
  SELECT DISTINCT tab0.application_name
                , DECODE (tab3.function_type,  'F', 'FUNCTION',  'O', 'FORM') FUNCTION_TYPE
                , tab2.form_name
                , tab1.user_form_name
                , tab6.data_object_code
    FROM FND_APPLICATION_TL tab0
       , FND_FORM_TL tab1
       , FND_FORM tab2
       , FND_ATTACHMENT_FUNCTIONS tab3
       , FND_ATTACHMENT_BLOCKS tab4
       , FND_ATTACHMENT_BLK_ENTITIES tab5
       , FND_DOCUMENT_ENTITIES tab6
   WHERE tab0.application_id = tab1.application_id
     AND tab1.form_id = tab2.form_id
     AND tab2.form_name = tab3.function_name
     AND tab3.attachment_function_id = tab4.attachment_function_id
     AND tab4.attachment_blk_id = tab5.attachment_blk_id
     AND tab5.data_object_code = tab6.data_object_code
     AND tab3.function_type = 'O'
     AND tab0.language = 'US'
     AND tab1.language = 'US'
  UNION ALL
  SELECT DISTINCT tab0.application_name
                , DECODE (tab3.function_type,  'F', 'FUNCTION',  'O', 'FORM') FUNCTION_TYPE
                , tab2.function_name
                , tab1.user_function_name
                , tab6.data_object_code
    FROM FND_APPLICATION_TL tab0
       , FND_FORM_FUNCTIONS_TL tab1
       , FND_FORM_FUNCTIONS tab2
       , FND_ATTACHMENT_FUNCTIONS tab3
       , FND_ATTACHMENT_BLOCKS tab4
       , FND_ATTACHMENT_BLK_ENTITIES tab5
       , FND_DOCUMENT_ENTITIES tab6
   WHERE tab1.function_id = tab2.function_id
     AND tab2.function_name = tab3.function_name
     AND tab3.attachment_function_id = tab4.attachment_function_id
     AND tab4.attachment_blk_id = tab5.attachment_blk_id
     AND tab5.data_object_code = tab6.data_object_code
     AND tab3.function_type = 'F'
     AND tab0.application_id = tab2.application_id
     AND tab0.language = 'US'
     AND tab1.language = 'US'
  ORDER BY 1, 2;
/