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

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

DECLARE

  --
  -- Local constants and variables
  --
  l_sql varchar2(32000);

BEGIN

  --
  -- Register Query Data Permissions by Set
  --
  l_sql :=
'        SELECT f.function_name permission_name
        FROM   fnd_menus m
              ,fnd_menu_entries e
              ,fnd_form_functions f
        WHERE  m.menu_name = upper(:pPermissionSet)
        AND    m.menu_id = e.menu_id
        AND    e.function_id = f.function_id
        AND    xxas_com_sec_pkg.test_instance(f.function_name, :pPrimaryKeyId) = ''Y''
        ORDER BY e.entry_sequence  ';

  xxas_com_sr_pkg.seed_query_service
    (p_service_name      => 'QueryDataPermissionsBySet'
    ,p_securing_function => 'XXAS_SRV_Q_PERM_SET_PERM'
    ,p_sql               => l_sql
    ,p_parameters        => xxas_com_sr_param_varray
                              (xxas_com_sr_param_type('pPermissionSet' , xxas_com_sr_pkg.g_VARCHAR2)
                              ,xxas_com_sr_param_type('pPrimaryKeyId'  , xxas_com_sr_pkg.g_VARCHAR2)));

END;
/
COMMIT;
EXIT;
