@echo off
verify # 2>nul
setlocal enableextensions enabledelayedexpansion
if errorlevel 1 goto CANT_SWITCH_ON_EXTENDED_CMD_PROCESSING
set concatenate_sql_cmd=1
call $SQLTRANS "(SettingsOnly)"
if !errorlevel! neq 0 goto ERROR
set OutputFileName=flat_owner_cabinet_programmatics.sql

if "%~0"=="CONCATENATE_SQL.cmd" goto START
cls

echo CONCATENATE SQL (FLAT OWNER CABINET):
echo ίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίί
echo.
rem echo ώ SQL-server  : !$sql_server!
rem echo ώ SQL-database: !$sql_database!
echo ώ Output file: !OutputFileName!
echo.
echo ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
echo ΝΝ STARTING THE SCRIPT(S) ON SQL-SERVER: ΝΝΝ (TRANSLATION CONFIRMATION) ΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ
echo.
call $CONFIRMPAUSE.cmd
if !errorlevel! neq 0 goto ERROR

:START
call :DELETE_READONLY_FILE "!OutputFileName!"
if !errorlevel! neq 0 goto FAILURE

set $sqltrans.TranslateToDatabase=0
set SqlCatPP.OutputFileName=!OutputFileName!
call $SQLTRANS.cmd "*.sql"
if !errorlevel! neq 0 goto FAILURE

:SUCCESS
if "%~0"=="CONCATENATE_SQL.cmd" goto FINISH
echo.
echo άάά CONCATENATE SQL ΔΔ SUCCESS άάά
goto FINISH

:FAILURE
if "%~0"=="CONCATENATE_SQL.cmd" goto ERROR
echo.
echo άάά ## CONCATENATE SQL ΔΔ FAILURE άάά
goto ERROR

::==================================================================================================

:CANT_SWITCH_ON_EXTENDED_CMD_PROCESSING
echo.
echo ## Can not switch on extended command processing.
goto ERROR

::==================================================================================================

:DELETE_READONLY_FILE
call :RESET_ERROR
if not exist "%~1" goto :EOF
echo.
echo * Deleting file: "%~1" ...
del /f /q "%~1"
if not exist "%~1" goto :EOF
goto :RETURN_ERROR

::==================================================================================================
:RESET_ERROR
set errorlevel=0
set errorlevel=
goto :EOF
::==================================================================================================
:ERROR
if not "%~0"=="CONCATENATE_SQL.cmd" (
echo 
if not "%$cmd_plain%"=="1" pause )
endlocal
verify # 2>nul
goto :EOF
:FINISH
endlocal
if not "%~0"=="CONCATENATE_SQL.cmd" (
echo.
if not "%$cmd_plain%"=="1" pause )
call :RESET_ERROR
goto :EOF
::==================================================================================================
