@echo off
@echo off
if "%1" == "" goto helptopic
if "%2" == "" goto helptopic
if "%ORACLE_HOME%" == "" goto envhelp
if "%ORACLE_SID%" == "" goto envhelp

echo \*\*\*
echo \*\*\* MAKE SURE your ORACLE_HOME, ORACLE_SID, PATH, and so on are
echo \*\*\* set appropriately!  This script must be able to utilize
echo \*\*\* sqlplus and sqlldr in order to load information into your
echo \*\*\* instance!
echo \*\*\*
echo \*\*\* This also assumes that CwMLite has already been installed.
echo \*\*\*
echo.
echo \*\*\* Next procedure will drop the user cs_olap and the related metadata
echo.

echo Removing log files from previous runs
echo \*\*\*
erase CHECK_USER.LOG
erase DROP.LOG

echo Connecting as SYS user
sqlplus "/ as sysdba" @0_check_user.sql %1 %2
findstr "CS_OLAP" CHECK_USER.LOG > nul
if not errorlevel 1 goto USER_ERROR 

echo Connecting as SYS user
sqlplus "/ as sysdba" @1_drop_all.sql %1 %2


echo
echo \*\*\*
echo \*\*\* Checking for errors in the log file
echo \*\*\*
findstr "error" DROP.LOG > nul
if NOT ERRORLEVEL 1 goto LOG_ERROR

findstr "ERROR" DROP.LOG > nul
if NOT ERRORLEVEL 1 goto LOG_ERROR

findstr "Error" DROP.LOG > nul
if NOT ERRORLEVEL 1 goto LOG_ERROR

echo
echo \*\*\*
echo \*\*\* CS_OLAP schema has been removed.  Have fun!
echo \*\*\*
goto end


:helptopic
echo.
echo.
echo Please specify the following two parameters when running the install:
echo - location of your Oracle9i cs_olap datafiles
echo - location of the shaw.eif file (source of the data for the analytic workspace)
echo.
echo For example:
echo install d:\Orahome1\oradata\my9iservice d:\beans
echo.
goto end

:envhelp
echo.
echo.
echo Please specify the following two parameters when running the install:
echo - Make sure your ORACLE_SID and ORACLE_HOME are correctly set
echo -
echo - for example SET ORACLE_SID=BEANS
echo -             SET ORACLE_HOME=D:\ORACLE\ORA92
echo.
goto end


:log_error
echo
echo \*\*\*
echo \*\*\* Errors in the log file, please review file DROP.LOG
echo \*\*\* and resolve the errors before re-running this script 
echo \*\*\*
goto end


:user_error
echo
echo \*\*\*
echo \*\*\* The user CS_OLAP is currently connected and cannot be dropped
echo \*\*\* Disconnect all CS_OLAP sessions and try again
echo \*\*\*
goto end

:end
