SQL 是或否重复功能

SQL yes or no to repeat function

goto1:

           --- update tabellen
    update dgdtw_lockedinfo set ciuserid = couserid where locknr = &lock;
    update dgdtw_topografie set locknr = '' where locknr = &lock;
    update dgdtw_topografie set verval=sysdate where id= &lock;
    commit;

    accept var prompt ' yes or no '

    if (var = yes) then 
    goto1

    and if (var = no)
       exit
    end if

如果用户输入是,则需要重复一个功能

有没有办法通过输入重复命令?

如果您确实必须这样做,请通过 start 命令使用递归来循环。

创建一个 'end of recursion' 文件 stop.sql,内容为:

prompt OK, end of repeat
exit

使用以下内容创建一个文件repeat.sql

set echo off verify off

select 'Your SQL statements go here' from dual;

accept var prompt 'Repeat the SQL statement [yes or no] ? '

define doit = 'stop.sql'
column doit new_value doit noprint
set termout off
select 'repeat.sql' doit from dual where upper('&var') like 'Y%';
set termout on
start &doit.

这是一个例子运行:

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jan 11 23:30:24 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options


'YOURSQLSTATEMENTSGOHERE'
---------------------------
Your SQL statements go here

Repeat the SQL statement [yes or no] ? yes

'YOURSQLSTATEMENTSGOHERE'
---------------------------
Your SQL statements go here

Repeat the SQL statement [yes or no] ? y

'YOURSQLSTATEMENTSGOHERE'
---------------------------
Your SQL statements go here

Repeat the SQL statement [yes or no] ? n
OK, no further repetitions.