How to create a menu in SQLPlus or PL/SQL(如何在 SQLPlus 或 PL/SQL 中创建菜单)
问题描述
我有几个脚本,我想从提供给 SQLPlus 用户的菜单开始.类似于:
请选择:
1:做脚本a
2:做脚本b
3:做脚本c
I have several scripts that I would like to start from a menu presented to the SQLPlus user. Something like:
Please make a selection:
1: Do script a
2: Do script b
3: Do script c
我只需要一个正确方向的观点,而不是一个快速的答案.
I just need a point in the right direction, not a quick answer.
推荐答案
这是一个 SQL Plus 脚本:
Here is a SQL Plus script to do that:
prompt Please make a selection:
prompt 1: Do script a
prompt 2: Do script b
prompt 3: Do script c
accept selection prompt "Enter option 1-3: "
set term off
column script new_value v_script
select case '&selection.'
when '1' then 'script_a'
when '2' then 'script_b'
when '3' then 'script_c'
else 'menu'
end as script
from dual;
set term on
@&v_script.
注意 case 表达式的 ELSE 部分中的菜单"是此脚本的名称,以便在用户输入无效选项时它会再次运行.
NB The 'menu' in the ELSE part of the case expression is the name of this script, so that it runs itself again when the user enters an invalid option.
这篇关于如何在 SQLPlus 或 PL/SQL 中创建菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 SQLPlus 或 PL/SQL 中创建菜单


- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01