--MARS-770
set verify off
SET serveroutput ON
--SET TIMING ON
whenever sqlerror exit sql.sqlcode rollback;
column owner format a15
column object_name format a30
column spoolname new_value spoolname 
select 'install_package_MarsGeneralRelease_MARS770_create_ODS_user_' || name || '_' ||to_char(sysdate,'YYYYMMDD_HH24MISS')||'.log' spoolname from v$pdbs;
spool '&spoolname'
prompt ##### started at time #####
select systimestamp from dual;
prompt ##### database name #####
select name pdb_name from v$pdbs;
--set echo on
--=============================================================================================================================
-- start install --MARS-770 create ODS user
--=============================================================================================================================

GRANT CONNECT, CREATE TABLE TO ODS;
GRANT READ, WRITE ON DIRECTORY DATA_PUMP_DIR TO ODS;
GRANT EXECUTE ON DBMS_CLOUD TO ODS;
EXEC DBMS_CLOUD_ADMIN.ENABLE_RESOURCE_PRINCIPAL(username => 'ODS');
GRANT EXECUTE ON CT_MRDS.FILE_MANAGER TO ODS;

-- GRANT SELECT ANY TABLE ON SCHEMA CT_MRDS TO ODS;
-- GRANT DELETE ANY TABLE ON SCHEMA CT_MRDS TO ODS;
-- GRANT INSERT ANY TABLE ON SCHEMA CT_MRDS TO ODS;
-- GRANT UPDATE ANY TABLE ON SCHEMA CT_MRDS TO ODS;
-- GRANT EXECUTE ANY  PROCEDURE ON SCHEMA CT_MRDS TO ODS;

GRANT SELECT ANY TABLE TO ODS;
GRANT DELETE ANY TABLE TO ODS;
GRANT INSERT ANY TABLE TO ODS;
GRANT UPDATE ANY TABLE TO ODS;
GRANT EXECUTE ANY  PROCEDURE TO ODS;

GRANT SELECT_CATALOG_ROLE TO ODS; 
GRANT SELECT ANY TABLE TO ODS;