Oracle SQL 输入问题
我需要编写一个脚本,提示 SQL+ 中的数据库用户输入存储过程的名称,然后将显示该存储过程的代码。
这将给我提示:
accept spinput prompt “Enter Stored Procedure Name:”
然后我可以输入存储过程名称。
然后,如果我运行此代码,将显示存储过程代码。
select text from user_source
where type = 'PROCEDURE'
and name = ‘&spinput’;
如何将所有内容合并到一个只要求输入并运行其余部分的脚本中?最好的方法是什么?
谢谢!
I need to write a script that will prompt a database user in SQL+ to type in the name of a stored procedure and then that stored procedure's code will be displayed.
This will give me the prompt:
accept spinput prompt “Enter Stored Procedure Name:”
Then I can type in the stored procedure name.
Then if I run this code, the stored procedure code will be displayed.
select text from user_source
where type = 'PROCEDURE'
and name = ‘&spinput’;
How do I combine that all into a script that just asks for the input and runs the rest? What is the best way to do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许我错过了一些东西,但你不是已经快到了吗?难道您不能将两个语句以及 prc.sql 中的一些格式化命令合并到一个文件中吗?
然后运行以下命令:
您的过程文本将输出到屏幕上。
我稍微修改了您的查询,将用户输入转换为大写,因为大多数情况下存储过程名称在数据库中都是大写的。这意味着用户可以不区分大小写地键入文本,并且将找到该过程。
Perhaps I'm missing something, but aren't you almost there? Can't you just combine your two statements into one file, along with some formatting commands in say, prc.sql:
Then run the following:
Your procedure text will be output to the screen.
I modified your query slightly to translate user input to upper case, since most of the time stored procedure names will be in upper case in the database. This means the user can type text without regard to case and the procedure will be found.