我正在尝试将show con_name的结果保存到oracle pl/sql sqlplus中的变量
我想写这样的东西:
exec show con_name in:= connection_name
,
但这不起作用。
我知道我可以做到这一点,但是我想知道以后的参考,是否有任何方法可以为show
exec oflect select seles sys_context('userEnv','con_name')in:connection_name from dual;
> connection_name
I want to write something like this:
exec SHOW CON_NAME into :=connection_name
but this doesnt work.
I know I can do this but I want to know for future reference if there is any way to do this for show
EXEC SELECT SYS_CONTEXT('USERENV','CON_NAME') into :connection_name from DUAL;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
exec
只是一个匿名块的包装器,因此即使
解决其他问题,
show> show
是sql*plus客户端命令,也不意味着什么在SQL或PL/SQL上下文中。您可以这样做:
避免在PL/SQL中从dual中选择的上下文开关。
Looking at the statement log in SQL Developer,
show con_name
is doing something similar, with acheckone
bind variable it uses internally;尽管它也将其通过本地PL/SQL变量,并将其修剪为30个字符。您还可以使用
列... new_value ...
和从dual查询,而无需使用PL/SQL,然后使用替换变量来稍后引用该值,而不是绑定变量:不确定那将是多么有用。取决于您想使用的是什么。
exec
is just a wrapper for an anonymous block, sois the same as
Even with other issues fixed,
show
is a SQL*Plus client command, and doesn't mean anything inside a SQL or PL/SQL context.You could do:
to avoid the context switch of selecting from dual within the PL/SQL.
Looking at the statement log in SQL Developer,
show con_name
is doing something similar, with acheckone
bind variable it uses internally; though it also puts it through a local PL/SQL variable and trims that to 30 chars.You could also use
column ... new_value ...
and query from dual, without using PL/SQL, and then use a substitution variable to refer to the value later instead of a bind variable:Not sure how useful that would be though. Depends what you want to use it for I suppose.