选择后不显示值(Batch,& Oracle)

时间:2018-04-03 06:55:28

标签: oracle batch-file batch-processing sqlplus

我正在做批处理文件,这是我到目前为止所做的:

@ECHO OFF

:start
echo Select Action:
echo 1 - Make Update
echo 2 - Revert Changes

set /p input=

If %input%==1 goto :choose1
If %input%==2 goto :choose2

:choose1
echo Selected Option 1
echo ENTER PASSWORD FOR USER:
SQLPLUS  -S USER@SID @update.sql
goto end

:choose2
echo Selected Option 2
REM it's just example
SQLPLUS  -S USER@PASSWORD\SID @reupdate.sql
goto end

:end
pause

运行它并选择1或2后,我显示了所选的数字:

enter image description here

我有两个问题:

1)如何显示"选择1" (标记为红色)

2)进入我的update.sql,我只写:

  update userB.tableA set column_name = 'XXX' where colZ = '123' and colT= 'ABC';
  exit;

没问题,或者我需要进入开始/结束?

1 个答案:

答案 0 :(得分:3)

使用cls可使批处理看起来更清晰,并删除不需要的项目,例如选择1

@echo off
:start
cls
echo ** Select an Action **:
echo 1 - Make Update
echo 2 - Revert Changes

set /p input=

If %input%==1 goto :choose1
If %input%==2 goto :choose2

:choose1
cls
echo You selected Option %input%
echo ENTER PASSWORD FOR USER:
SQLPLUS  -S USER@SID @update.sql
goto end

:choose2
cls
echo You selected Option %input%
REM it's just example
SQLPLUS  -S USER@PASSWORD\SID @reupdate.sql
goto end

:end
pause

或使用选择命令而不是set /p

@echo off
cls
:start
echo 
echo Select 1 - Make Update\n
echo Select 2 - Revert Changes

choice /c 12 /n

If %errorlevel%==1 goto :choose1
If %errorlevel%==2 goto :choose2

:choose1
cls
echo You selected Option %errorlevel%
echo ENTER PASSWORD FOR USER:
SQLPLUS  -S USER@SID @update.sql
goto end

:choose2
 cls
echo You selected Option %errorlevel%
REM it's just example
SQLPLUS  -S USER@PASSWORD\SID @reupdate.sql
goto end

:end
pause

然后在问题2中,添加开始/结尾只会使其成为plsql,因此除非您需要plsql脚本,否则不需要。