/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2018 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

CREATE OR REPLACE VIEW XXAS_DATA_SOURCE_DEFAULT_GRANT
AS 
SELECT d.rowid row_id
      ,b.function_id
      ,b.function_name
      ,b.parameters    function_parameters
      ,d.function_id   data_function_id
      ,d.function_name data_function_name
      ,d.parameters    data_function_parameters
      ,d.application_id
      ,d.creation_date
      ,d.created_by
      ,d.last_update_date
      ,d.last_updated_by
      ,d.last_update_login
      ,d.type
      ,t.user_function_name
      ,t.description
      ,fo.object_id
      ,decode(fo.object_id,null,'N','Y') obj_exists_flag
FROM   fnd_form_functions_tl t
      ,fnd_form_functions b
      ,fnd_form_functions d
      ,fnd_objects fo
WHERE  b.function_id = t.function_id
AND    t.language    = userenv('LANG')
AND    d.function_id(+) = xxas_com_sec_pkg.get_function_id(nvl(xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pDataFunction')
                                          ,xxas_com_sec_pkg.get_parameter_value(b.parameters, 'pPayslipsDataFunction')))
AND    d.object_id = fo.object_id(+);

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_DATA_SOURCE_DEFAULT_GRANT'
   ,p_description            => 'Applaud Default Data Source Grants');
END;
/
COMMIT;
EXIT;
