如何用sqlplus用引号的字符串打印
此问题
define a='eee"dd'
prompt &a -- eee"dd OK
host powershell.exe echo '&a'; -- eeedd not OK
host powershell.exe echo &a; -- eeedd not OK
可以看出,我无法用SQL Plus的Powershell中的引号打印一个引用。 有办法做到吗?
当值来自查询时,我已经尝试了Alex Poole的解决方案。但是如果有一个以上的报价字符串,它不起作用。
column a new_value a
select replace('eee"d"d', '"', '""') as a from dual;
prompt &a -- eee""d""d Ok as expected
host powershell.exe echo '"&a"'-- eee"dd instead of eee"d"d
Sequel from this question
define a='eee"dd'
prompt &a -- eee"dd OK
host powershell.exe echo '&a'; -- eeedd not OK
host powershell.exe echo &a; -- eeedd not OK
As you can see, I can't print a stirng with a quotation quote in powershell from sql plus.
Is there a way to do that.?
I've tried the solution of Alex Poole when the value comes from a query.But it's not working if there is more than one quotation string.
column a new_value a
select replace('eee"d"d', '"', '""') as a from dual;
prompt &a -- eee""d""d Ok as expected
host powershell.exe echo '"&a"'-- eee"dd instead of eee"d"d
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为我工作
works for me
如果您逃脱了报价,似乎有效(用于PowerShell的福利)通过在值,和中使用
“”
,和使用两种类型的引号好处:如果您实际上是从查询中填充
a
变量,如以前的问题,您可以replace()
引用:It seems to work if you escape the quote (for PowerShell's benefit) by using
""
within the value, and use both types of quotes, for both PowerShell's and SQL*Plus's benefit:If you are actually populating the
a
variable from a query, as in your previous questions, then you canreplace()
quotes with: