1

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

2 Answers 2

1

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;
Sign up to request clarification or add additional context in comments.

3 Comments

thanks for your answer. I's not working if I use more than one quotation quote. I've given a exemple in my question.
That seems to be a PowerShell issue... from the command line, one of their sample strings "As they say, ""live and learn.""" works, but not with anything between the 'real' closing quote and the string-ending quote, even a space, e.g. "As they say, ""live and learn."" ".
Without cmd.exe in the picture, the robust way to escape " chars. for the PowerShell CLI with the (possibly implied) -Command parameter is to use \". With cmd.exe in the picture, this may break situationally, and the workaround depends on the edition of PowerShell you use - see this answer.
1
column a new_value a
select replace('eee"d"d', '"', '\"') as a from dual;
host powershell.exe echo '&a'

works for me

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.