Reputation: 3986
I want to run oracle query through PowerShell. Single line query is running fine with no error. But now I have to run multi-line query.
set lines 400
select name,host_name,status,open_mode,to_char(startup_time,'DD-Mon-yy HH24:MI:SS') STARTUP_TIME from v$inst,v$db;
I tried this
$sql=@(
"set lines 400
select name,host_name,status,open_mode,to_char(startup_time,'DD-Mon-yy HH24:MI:SS') STARTUP_TIME from v`$inst,v`$db"
)
And multiple options but it is giving me error ORA-00922.
I am using ODP.net in PowerShell.
Please advise.
Update:
If I run this query in oracle(without PowerShell) then it is working fine.
Upvotes: 0
Views: 987
Reputation: 8889
Your $SQL Variable is an Array with only one line:
$sql.Count
1
Try create it in that way:
$sql = @()
$sql += 'set lines 400'
$sql += 'select name,host_name,status,open_mode,to_char(startup_time,''DD-Mon-yy HH24:MI:SS'') STARTUP_TIME from v`$inst,v`$db"'
Important Note:
When using 'Quotes' inside the string you should add ''Dobule Quoutes'' otherwise it will be illegal - like this: ''DD-Mon-yy HH24:MI:SS''
Upvotes: 1