if x%4==x goto usage
SET DBPRV=%1
SET DBPRVPATH=%2
SET DBVER=%3
SET BUILD=%4

SET targetUSER=TEST_DB%1TODB%3
SET targetPASS=TEST_DB%1TODB%3
SET targetSERVER=WORK

SET logger=%targetSERVER%_%targetUSER%_%~n1.log

set oracle_sid=%targetSERVER%
@TITLE Creating %targetUSER%@%targetSERVER%
@ECHO Creating %targetUSER%@%targetSERVER%
sqlplus.exe system/XZSTXnHGjfNNODfQc@%targetSERVER% @.\CreateUser%targetSERVER%.sql %targetUSER% %targetPASS%
@if errorlevel 1 goto nocreate

@TITLE Running FCLT%DBPRV%.sql
ECHO @@%DBPRVPATH% >xtmp.sql
ECHO UPDATE fac_version SET fac_version_cust = 'CREA'; >>xtmp.sql
ECHO EXIT >>xtmp.sql
sqlplus.exe %targetUSER%/%targetPASS%@%targetSERVER% @xtmp.sql | FINDSTR /C:"BEGIN adm.sys" /C:"ORA-" /C:"SP2-" /C:"Waarschuwing: package-body is aangemaakt met compilatiefouten."

@TITLE Running DB%DBPRV%to%DBVER%.sql
ECHO define ACCEPT_DB%DBVER%=1 >xtmp.sql
ECHO @%BUILD%\DB%DBVER%\DB%DBPRV%to%DBVER%.sql >>xtmp.sql
ECHO @@z:\Project\FACILITOR\Database\trunk\_UTIL\SUPPORT_IDP\supportJWT_SAAS.sql >>xtmp.sql
ECHO EXIT >>xtmp.sql
sqlplus.exe %targetUSER%/%targetPASS%@%targetSERVER% @xtmp.sql | FINDSTR /C:"BEGIN adm.sys" /C:"ORA-" /C:"SP2-" /C:"Waarschuwing: package-body is aangemaakt met compilatiefouten."
DEL xtmp.sql
goto end

:usage
echo gebruik: %0 27 path/to/CREA27.sql 28 path/to/build
echo Test het upgrade script
pause
goto end

:nocreate
@echo ===============================================================================
@echo Het is niet gelukt gebruiker %targetUSER%@%targetSERVER% goed aan te maken
pause
goto end

:end
