Rem  Copyright (c) Oracle Corporation 2014. All Rights Reserved.
Rem
Rem    NAME
Rem      ords_grant_privs.sql
Rem
Rem    DESCRIPTION
Rem      Object privileges and system privileges for Oracle REST Data Services (ORDS_METADATA) user.
Rem      Do not invoke this script directly.  If you are doing a manual installation, use ords_manual_install.sql
Rem
Rem    NOTES
Rem      Assumes user with SYSDBA privilege is connected.
Rem
Rem    Arguments:
Rem      1  : Oracle Rest Data Services (ORDS) schema
Rem
Rem
Rem    MODIFIED   (MM/DD/YYYY)
Rem     epaglina   08/21/2015 - Granting default_job_class to support lock-down restrictions.
Rem     epaglina   08/18/2015 - Granting dbms_scheduler to support lock-down restrictions.
Rem     epaglina   08/17/2015 - Granting session_roles to support lock-down restrictions.
Rem     josmende   02/18/2015 - Granting create job for ORDS sessions cleanup job creation.
Rem     epaglina   01/28/2014 - Created.
Rem

set define '^' 
set verify off

define ORDSUSER   = '^1'

whenever sqlerror exit sql.sqlcode

prompt INFO: Grant object and system privileges to ORDS owner

--
-- Object privileges
--
grant execute on sys.dbms_assert         to ^ORDSUSER;
grant execute on sys.dbms_crypto         to ^ORDSUSER;
grant execute on sys.dbms_lob            to ^ORDSUSER;
grant execute on sys.dbms_output         to ^ORDSUSER;
grant execute on sys.dbms_registry       to ^ORDSUSER;
grant execute on sys.dbms_scheduler      to ^ORDSUSER;
grant execute on sys.dbms_session        to ^ORDSUSER;
grant execute on sys.dbms_utility        to ^ORDSUSER;
grant execute on sys.default_job_class   to ^ORDSUSER;
grant execute on sys.htf                 to ^ORDSUSER;
grant execute on sys.htp                 to ^ORDSUSER;
grant execute on sys.owa                 to ^ORDSUSER;
grant execute on sys.validate_ords       to ^ORDSUSER;
grant execute on sys.wpg_docload         to ^ORDSUSER;

grant select  on sys.dba_directories     to ^ORDSUSER;
grant select  on sys.dba_objects         to ^ORDSUSER;
grant select  on sys.session_roles       to ^ORDSUSER;

--
-- System privileges
--
grant alter user               to ^ORDSUSER;
grant create any trigger       to ^ORDSUSER;

--
-- Installation exclusive privileges (temporal)
--
grant create job               to ^ORDSUSER;

prompt INFO: Completed granting object and system privileges
