在Powershell中的Oracle查询中使用II运算符

时间:2013-01-23 14:59:57

标签: oracle powershell plsql

我正在尝试定义要用于Oracle数据库的$ queryString。我还需要能够将某些查询与||连接起来运营商。我认为问题是Powershell将其视为管道运营商。我也试过以\ |的形式使用转义和''|但似乎都不起作用。供参考,这是我正在使用的查询。

$queryString = 'select v.npa || v.calling_number phone_number, v.location, v.customer_name '
$queryString += 'from voip_validate v '
$queryString += 'left outer join phone_numbers p '
$queryString += 'on v.npa || v.calling_number = p.area_code || p.phone_prefix || p.phone_suffix '
$queryString += 'left outer join mv_dps_buildings b '
$queryString += 'on b.dps_building_number = p.dps_building_number '
$queryString += 'where p.area_code is null '
$queryString += 'and p.phone_prefix is null '
$queryString += 'and p.phone_suffix is null; '

1 个答案:

答案 0 :(得分:3)

使用here-string(http://technet.microsoft.com/en-us/library/ee692792.aspx):

$queryString = @'
select v.npa || v.calling_number phone_number, v.location, v.customer_name 
from voip_validate v 
left outer join phone_numbers p 
on v.npa || v.calling_number = p.area_code || p.phone_prefix || p.phone_suffix 
left outer join mv_dps_buildings b 
on b.dps_building_number = p.dps_building_number 
where p.area_code is null 
and p.phone_prefix is null 
and p.phone_suffix is null; 
'@

PS>$queryString
select v.npa || v.calling_number phone_number, v.location, v.customer_name
from voip_validate v
left outer join phone_numbers p
on v.npa || v.calling_number = p.area_code || p.phone_prefix || p.phone_suffix
left outer join mv_dps_buildings b
on b.dps_building_number = p.dps_building_number
where p.area_code is null
and p.phone_prefix is null
and p.phone_suffix is null;