问题的续集
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正如您所看到的,我无法在powershell中打印来自sql的引号。有什么办法可以做到吗?
我已经尝试过Alex的解决方案,当值来自一个query.But时,如果有多个引号字符串,它就不能工作。
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发布于 2022-06-07 08:31:07
如果您通过在值中使用为了PowerShell的利益来规避引号( "" ),并使用这两种类型的引号,这似乎是可行的,因为PowerShell和SQL*Plus都有好处:
SQL> define a='eee""dd'
SQL> host powershell.exe echo '"&a"'
eee"dd如果您实际上正在从查询中填充a变量,就像在前面的问题中一样,那么您可以用以下方式引用replace():
column a new_value a
select replace('eee"dd', '"', '""') as a from dual;发布于 2022-06-07 09:31:59
column a new_value a
select replace('eee"d"d', '"', '\"') as a from dual;
host powershell.exe echo '&a'为我工作
https://stackoverflow.com/questions/72527899
复制相似问题