這個問題的續集
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
uj5u.com熱心網友回復:
如果您通過在值中使用來轉義引號(為了 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;
uj5u.com熱心網友回復:
column a new_value a
select replace('eee"d"d', '"', '\"') as a from dual;
host powershell.exe echo '&a'
為我作業
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/487520.html
上一篇:如何在AzureDevOpsyaml管道的每個回圈中使用變數
下一篇:目錄串列內遞回父子
