SET VERIFY ON
SET HEAD ON
SET FEEDBACK 1
SET ARRAY 1
SET LINESIZE 10000
SET PAGESIZE 50000
SET LONG 10000
SET ECHO ON
SET TRIMSPOOL ON
SET COLSEP ';'
SET SERVEROUT OFF
clear screen
SPOOL ON
SET SQLBLANKLINES ON
SET SERVEROUTPUT ON
SET ERRORLOGGING ON
SET ECHO ON
prompt Welcome to Application PDB Configuration
SPOOL "&SPOOL_PATH"
/* Inputs are recieved */
/* Connect CDB as sys user */
accept P_CDB_USER Prompt 'Enter CDB Schema Username: '
accept P_CDB_PWD Prompt  'Enter CDB Schema Password: '
accept P_CDB_HOST Prompt 'Enter CDB Schema Host: '
accept P_CDB_PORT Prompt 'Enter CDB Schema Port: '
accept P_APPROOT_NAME Prompt 'Enter Application Root Name: '
accept P_APPLICATION_NAME Prompt   'Enter application name to be installed: '
accept P_COMMON_USER Prompt 'Enter Common User Name: '

/* Connecting to Application Root As SYSDBA*/
conn &P_CDB_USER/&P_CDB_PWD@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=&P_CDB_HOST)(PORT=&P_CDB_PORT)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=&P_APPROOT_NAME))) as sysdba;

alter pluggable database application &P_APPLICATION_NAME begin install '1.0';
	exec dbms_pdb.set_user_explicit('&P_COMMON_USER');
alter pluggable database application &P_APPLICATION_NAME end install;

SET ERRORLOGGING OFF
SPOOL OFF