首页 > 代码库 > DOS 选项跳转实现、dos + bcp 双击导入导出数据

DOS 选项跳转实现、dos + bcp 双击导入导出数据

DOS 选项跳转实现、dos + bcp 双击导入导出数据

  • option.bat

@echo off
:Start2 
cls
goto Start
:Start
title Frequently Used Websites
echo Please select a website from the list
echo with the corresponding key
echo --------------------------------------
echo [1] Google
echo [2] Wikipedia
echo [3] Facebook
echo [4] Youtube
echo [5] Yahoo
set input=
set /p input= Choice:
if "%input%" =="" goto N
if %input%==1 goto Z if NOT goto Start2
if %input%==2 goto X if NOT goto Start2
if %input%==3 goto C if NOT goto Start2
if %input%==4 goto V if NOT goto Start2
if %input%==5 goto B if NOT goto Start2
if %input% gtr 5 goto N

:Z
cls
echo You have selected Google
pause
start www.google.com
exit
:X
cls
echo You have selected Wikipedia
pause
start www.wikipedia.com
exit
:C
cls
echo You have selected Facebook
pause
start www.facebook.com
exit
:V
cls
echo You have selected Youtube
pause
start www.youtube.com
exit
:B
cls
echo You have selected Yahoo
pause
start www.Yahoo.com
exit
:N
cls
echo Invalid Selection! Try again
pause
goto :start2


  • Mantis0000225_ExportSalesOrder_Autosys.cmd

@cls
@echo OFF
@set "endfix=%date:~,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%"
@SETLOCAL ENABLEEXTENSIONS
@SETLOCAL ENABLEDELAYEDEXPANSION
@echo ...
@echo VALIDATE ENVIRONMENT VARIABLES ...
rem +--------------------------------------------------------------------------+
rem | VALIDATE ENVIRONMENT VARIABLES                                           |
rem +--------------------------------------------------------------------------+

@set MSBACKUP=D:\SalesOrder_NEWDRM
@set MSLOG=D:\SalesOrder_NEWDRM
@set MSTMP=D:\SalesOrder_NEWDRM
@echo ...
@echo DECLARE ALL GLOBAL VARIABLES...
rem +--------------------------------------------------------------------------+
rem | DECLARE ALL GLOBAL VARIABLES.                                            |
rem +--------------------------------------------------------------------------+

@set FILENAME=SALESORDER
@set DB_USERNAME=DRMPOS
@set DB_PASSWORD=DRMPOS
@set TNS_ALIAS=DRMPROD
@set LOGFILE=%MSLOG%\%FILENAME%_%TNS_ALIAS%.log
@set DUMPFILE=%MSBACKUP%\%FILENAME%_%TNS_ALIAS%.dat
rem +--------------------------------------------------------------------------+
rem | WRITE EXPORT PARAMETER FILE.                                             |
rem +--------------------------------------------------------------------------+
@echo ...
@echo MOVE OLD EXPORT (DUMP) FILE....
rem +--------------------------------------------------------------------------+
rem | MOVE OLD EXPORT (DUMP) FILE.                                             |
rem +--------------------------------------------------------------------------+

@if exist "%DUMPFILE%.backup" (del /q "%DUMPFILE%.backup")

@if exist %DUMPFILE% (echo f|@xcopy /y   %DUMPFILE% %DUMPFILE%.backup)
@if exist %LOGFILE% (echo f|xcopy /y  %LOGFILE% "%LOGFILE%.%endfix%")
@if exist "%LOGFILE%.%endfix%" (echo f | xcopy /y  "%LOGFILE%.%endfix%" D:\SalesOrder_NEWDRM\logfile\&del /q "%LOGFILE%.%endfix%")
@if exist %LOGFILE% (del /q %LOGFILE%)
@echo ...
@echo PERFORM EXPORT...
rem +--------------------------------------------------------------------------+
rem | PERFORM EXPORT.                                                          |
rem +--------------------------------------------------------------------------+

rem exp parfile=%PARFILE%
@bcp " select * from drmpos.SALESORDER where orderdate >= convert(DATE,getdate()-10)" queryout %DUMPFILE% -T -c -t^| -d apoms -e %LOGFILE% 
 
@IF not EXIST %LOGFILE% GOTO end

@echo ...error occured
@echo SCAN THE EXPORT LOGFILE FOR ERRORS...
rem +--------------------------------------------------------------------------+
rem | SCAN THE EXPORT LOGFILE FOR ERRORS.                                      |
rem +--------------------------------------------------------------------------+
@echo ...
@echo Analyzing log file for errors...
@findstr /I /C:"Export terminated unsuccessfully" %LOGFILE%
@if errorlevel 1 (goto good1) else (goto exception)
:END
@echo ...
@echo finished WITHOUT errorlog
@exit /b 0
:good1
@echo ...
@echo Analyzing log file for MS-errors...
@findstr /I /C:"invalid" %LOGFILE%
@if errorlevel 1 (goto good2) else (goto exception)

:good2
@echo ...
@echo Analyzing log file for warnings...
@findstr /I /C:"error" %LOGFILE%
@if errorlevel 1 (goto good3) else (goto exception)

:good3
@echo ...
@echo Analyzing log file for warnings...
@findstr /I /C:"rows" %LOGFILE%
@if errorlevel 1 (cmd /c exit 0) else (goto exception)
@exit /b 0

:exception
@exit /b 1


  • Mantis0000227_ImportSalesOrder_Autosys.cmd
@cls
@echo OFF
@set "endfix=%date:~,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%"
@SETLOCAL ENABLEEXTENSIONS
@SETLOCAL ENABLEDELAYEDEXPANSION
@echo ...
@echo VALIDATE ENVIRONMENT VARIABLES ...
rem +--------------------------------------------------------------------------+
rem | VALIDATE ENVIRONMENT VARIABLES                                           |
rem +--------------------------------------------------------------------------+

@set MSBACKUP=D:\SalesOrder_NEWDRM
@set MSLOG=D:\SalesOrder_NEWDRM
@set MSTMP=D:\SalesOrder_NEWDRM
@echo ...
@echo DECLARE ALL GLOBAL VARIABLES...
rem +--------------------------------------------------------------------------+
rem | DECLARE ALL GLOBAL VARIABLES.                                            |
rem +--------------------------------------------------------------------------+

@set FILENAME=SALESORDER
@set DB_USERNAME=DRMPOS
@set DB_PASSWORD=DRMPOS
@set TNS_ALIAS=DRMPROD
@set LOGFILE=%MSLOG%\IMP_%FILENAME%_%TNS_ALIAS%.log
@set DUMPFILE=%MSBACKUP%\%FILENAME%_%TNS_ALIAS%.dat
rem +--------------------------------------------------------------------------+
rem | WRITE EXPORT PARAMETER FILE.                                             |
rem +--------------------------------------------------------------------------+
@echo ...
@echo MOVE OLD EXPORT (DUMP) FILE....
rem +--------------------------------------------------------------------------+
rem | MOVE OLD EXPORT (DUMP) FILE.                                             |
rem +--------------------------------------------------------------------------+

@if exist "%DUMPFILE%.backup" (del /q "%DUMPFILE%.backup")

@if exist %DUMPFILE% (echo f|@xcopy /y   %DUMPFILE% %DUMPFILE%.backup)
@if exist %LOGFILE% (echo f|xcopy /y  %LOGFILE% "%LOGFILE%.%endfix%")
@if exist "%LOGFILE%.%endfix%" (echo f | xcopy /y  "%LOGFILE%.%endfix%" D:\SalesOrder_NEWDRM\logfile\&del /q "%LOGFILE%.%endfix%")
@if exist %LOGFILE% (del /q %LOGFILE%)
@echo ...
@echo PERFORM EXPORT...
rem +--------------------------------------------------------------------------+
rem | PERFORM EXPORT.                                                          |
rem +--------------------------------------------------------------------------+

rem exp parfile=%PARFILE%
@bcp apoms.drmpos.SALESORDER in %DUMPFILE% -T -c -t^|  -e %LOGFILE% 
 
@IF not EXIST %LOGFILE% GOTO end

@echo ...error occured
@echo SCAN THE EXPORT LOGFILE FOR ERRORS...
rem +--------------------------------------------------------------------------+
rem | SCAN THE EXPORT LOGFILE FOR ERRORS.                                      |
rem +--------------------------------------------------------------------------+
@echo ...
@echo Analyzing log file for errors...
@findstr /I /C:"Export terminated unsuccessfully" %LOGFILE%
@if errorlevel 1 (goto good1) else (goto exception)
:END
@echo ...
@echo finished WITHOUT errorlog
@exit /b 0

echo ...
echo Analyzing log file for errors...
findstr /I /C:"Import terminated unsuccessfully" %LOGFILE%
if errorlevel 1 (goto good1) else (goto exception)

:good1
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"communication" %LOGFILE%
if errorlevel 1 (goto good2) else (goto exception)

:good2
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"errors" %LOGFILE%
if errorlevel 1 (goto good3) else (goto exception)

:good3
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"Snapshot" %LOGFILE%
if errorlevel 1 (goto good4) else (goto exception)

:good4
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"TNS" %LOGFILE%
if errorlevel 1 (goto good5) else (goto exception)

:good5
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"resource" %LOGFILE%
if errorlevel 1 (goto good6) else (goto exception)

:good6
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"deadlock" %LOGFILE%
if errorlevel 1 (goto good7) else (goto exception)

:good7
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"identifier" %LOGFILE%
if errorlevel 1 (goto good8) else (goto exception)

:good8
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"maximum" %LOGFILE%
if errorlevel 1 (goto good9) else (goto exception)

:good9
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"shutdown" %LOGFILE%
if errorlevel 1 (goto good10) else (goto exception)

:good10
echo ...
echo Analyzing log file for warnings...
findstr /I /C:"unable" %LOGFILE%
if errorlevel 1 (cmd /c exit 0) else (goto exception)

exit /b 0

:exception
exit /b 1


DOS 选项跳转实现、dos + bcp 双击导入导出数据