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
CodePudding user response:
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:
SQL> define a='eee""dd'
SQL> host powershell.exe echo '"&a"'
eee"dd
If you are actually populating the a
variable from a query, as in your previous questions, then you can replace()
quotes with:
column a new_value a
select replace('eee"dd', '"', '""') as a from dual;
CodePudding user response:
column a new_value a
select replace('eee"d"d', '"', '\"') as a from dual;
host powershell.exe echo '&a'
works for me