|
@echo off
|
|
setlocal EnableExtensions EnableDelayedExpansion
|
|
|
|
set mastersoft_dir=C:\Mastersoft
|
|
set dbadm=%mastersoft_dir%\Deployment\DbAdm\DbAdm.exe
|
|
set sysexp=%mastersoft_dir%\Deployment\SysExp\SysExp.exe
|
|
set dsn=IPSDATABASE
|
|
|
|
if "%~1" neq "" (
|
|
set dsn=%~1
|
|
)
|
|
|
|
set /p table="Enter table number to reload: "
|
|
if /I "!table!" equ "" (
|
|
goto:eof
|
|
) else (
|
|
echo Table %table% of "%dsn%" will be reloaded
|
|
)
|
|
|
|
set /p UserAgree=Continue? (y/n):
|
|
if /I "%UserAgree%" neq "y" (
|
|
goto:eof
|
|
)
|
|
|
|
set /a table_num=%table%
|
|
if %table_num% equ 43 (
|
|
echo Reloading of table 43 is not supported. Exiting...
|
|
exit /b 1
|
|
) else (
|
|
if %table_num% lss 100 (
|
|
set table_num=0%table%
|
|
set table_num=!table_num:~-2!
|
|
) else (
|
|
set table_num=%table%
|
|
)
|
|
echo Copying data to a temporary table...
|
|
echo select * into DATA_!table_num!_copy from DATA_!table_num!;>query.sql
|
|
%dbadm% --opts=nokey --dsn=%dsn% --script --file=query.sql
|
|
if ERRORLEVEL 1 exit /b 1
|
|
echo Dropping original table...
|
|
echo drop table DATA_!table_num!;>query.sql
|
|
%dbadm% --opts=nokey --dsn=%dsn% --script --file=query.sql
|
|
if ERRORLEVEL 1 exit /b 1
|
|
echo Copying data to the destination table...
|
|
echo select * into DATA_!table_num! from DATA_!table_num!_copy;>query.sql
|
|
%dbadm% --opts=nokey --dsn=%dsn% --script --file=query.sql
|
|
if ERRORLEVEL 1 exit /b 1
|
|
echo Dropping copy table...
|
|
echo drop table DATA_!table_num!_copy;>query.sql
|
|
%dbadm% --opts=nokey --dsn=%dsn% --script --file=query.sql
|
|
if ERRORLEVEL 1 exit /b 1
|
|
|
|
%dbadm% --opts=nokey --dsn=%dsn% --migrate --tables=%table%
|
|
if ERRORLEVEL 1 exit /b 1
|
|
echo Table %table% reloaded successfully.
|
|
)
|