set verify off
PROMPT 'CREATI DIRECTORUL [C:\DMPDIR\] PENTRU IMPORTUL DUMP-URILOR SI COPIATI FISIERELE CONTAFIN_ORACLE.DMP SI FIRMANOUA.DMP!'

ACCEPT systemPassword CHAR PROMPT 'Specificati parola pentru SYSTEM>'
PROMPT

ACCEPT oraSID CHAR PROMPT 'Specificati SID-ul bazei de date>'
PROMPT

ACCEPT dataDirectory CHAR PROMPT 'Specificati directorul unde se va instala baza de date (fara \ la sfarsit)>'
PROMPT

ACCEPT coPassword CHAR PROMPT 'Specificati parola pentru Contafin Oracle>'
PROMPT

ACCEPT fnName CHAR PROMPT 'Specificati numele pentru firma noua>'
PROMPT

ACCEPT fnPassword CHAR PROMPT 'Specificati parola pentru &&fnName>'
PROMPT

connect SYSTEM/&&systemPassword@&&oraSID

PROMPT se creeaza tablespace ROA
@CreateDB.sql

PROMPT se creeaza userul CONTAFIN_ORACLE
@CreateCO.sql

PROMPT se creeaza userul <FIRMA>
@CreateFN.sql

disconnect

-- se importa scripturi pe sys
connect SYS/&&systemPassword@&&oraSID as sysdba
@sys_2006_06_26_01.sql
@sys_2007_03_26_01.sql
@sys_2007_12_11_01.sql
@sys_2009_09_15_01_LICENTA.sql
@sys_2012_06_19_01_LOG.sql
@sys_2012_06_21_01_FIRMA.sql
@sys_2012_06_21_02_PACK_AUTH.sql
@sys_2013_01_23_01_PACK_AUTH.sql
@sys_2013_01_23_01_PACK_AUTH.sql
@sys_2013_01_23_02.sql
@sys_2013_06_17_01_COMUN.sql
@sys_2013_07_18_01_AUTH_PACK.sql
@sys_2013_07_24_01.sql
@sys_2013_08_29_01_AUTH_PACK.sql
@sys_2014_07_10_01_FIRMA.sql
@sys_2014_07_24_01.sql
@sys_2014_08_18_01.sql
@sys_2014_08_18_02_UPDATE_UPDATESQLPLUS.sql
@sys_2014_08_18_03_UPDATE.sql
@sys_2014_09_04_01_FIRMA.sql
@sys_2014_10_10_01_DREPTURI.sql
@sys_2014_10_21_01_FIRMA.sql
@sys_2014_11_06_01_FIRMA.sql
@sys_2017_02_28_01_SCHEMA.sql
@sys_2020_04_07_01_SCHEMA.sql
@sys_2020_07_01_01_AUTH_PACK.sql
@sys_2021_12_08_01_COMUN.sql
@sys_2023_05_03_01_COMUN.sql
@sys_2024_02_22_01_COMUN.sql
@sys_2025_09_24_03_EXECUTESCRIPTOS.sql
@sys_2026_01_14_01_AUTH_PACK.sql

--------------------------------------------------
create or replace view vauth_serii as
select a.id_program,
       a.denumire as nume,
       auth_pack.selecteaza_serie(a.id_program) as serie,
       auth_pack.selecteaza_nr_util(a.id_program) as nr_util,
       auth_pack.selecteaza_data_val(a.id_program) as data_val
  from syn_nom_programe a
  left join syn_def_programe b on a.id_program = b.ide_program
 where b.sters = 0
   and b.instalat = 1
   /
--------------------------------------------------
   

disconnect


spool import_co.bat

rem imp SYSTEM/&&systemPassword@&&oraSID fromuser=CONTAFIN_ORACLE touser=CONTAFIN_ORACLE file=contafin_oracle.dmp log=contafin_oracle.log
PROMPT impdp SYSTEM/&&systemPassword@&&oraSID directory=DMPDIR dumpfile=contafin_oracle.dmp logfile=contafin_oracle.log

spool off


spool post_co.bat

PROMPT sqlplus SYSTEM/&&systemPassword@&&oraSID @postdbcreation.sql

spool off


spool import_firma.bat

REM imp SYSTEM/&&systemPassword@&&oraSID fromuser=firmanoua touser=&&fnName file=firmanoua.dmp log=&&fnName.log
PROMPT impdp SYSTEM/&&systemPassword@&&oraSID directory=DMPDIR dumpfile=firmanoua.dmp logfile=&&fnName..log remap_schema=firmanoua:&&fnName

spool off
quit