我目前有一个如下所示的 powershell 脚本:
$Query = "SELECT
t1.BSM_NM
,t1.D_DTM AS MAXDATETIME
,t1.TECHNOLOGY
,t1.VOICEDATA
,CASE
WHEN t1.VOICEDATA = 'VOICE'
AND
(
t1.CUST_BLK_CNT/t1.ATT_CNT >= t2.MAJOR_VOICE_BLOCK AND t1.CUST_BLK_CNT/t1.ATT_CNT < t2.CRITICAL_VOICE_BLOCK
OR
t1.DRP_CALL_CNT/t1.ATT_CNT >= t2.MAJOR_VOICE_DROP AND t1.DRP_CALL_CNT/t1.ATT_CNT < t2.CRITICAL_VOICE_DROP
OR
t1.AXS_F_CNT/t1.ATT_CNT >= t2.MAJOR_VOICE_AXSFAIL AND t1.AXS_F_CNT/t1.ATT_CNT < t2.CRITICAL_VOICE_AXSFAIL
)
THEN 1
WHEN t1.VOICEDATA = 'DATA'
AND
(
t1.CUST_BLK_CNT/t1.ATT_CNT >= t2.MAJOR_VOICE_BLOCK AND t1.CUST_BLK_CNT/t1.ATT_CNT < t2.CRITICAL_DATA_BLOCK
OR
t1.DRP_CALL_CNT/t1.ATT_CNT >= t2.MAJOR_VOICE_DROP AND t1.DRP_CALL_CNT/t1.ATT_CNT < t2.CRITICAL_DATA_DROP
OR
t1.AXS_F_CNT/t1.ATT_CNT >= t2.MAJOR_VOICE_AXSFAIL AND t1.AXS_F_CNT/t1.ATT_CNT < t2.CRITICAL_DATA_AXSFAIL
)
THEN 1
WHEN t1.VOICEDATA = 'VOICE'
AND
(
t1.CUST_BLK_CNT/t1.ATT_CNT >= t2.CRITICAL_VOICE_BLOCK
OR
t1.DRP_CALL_CNT/t1.ATT_CNT >= t2.CRITICAL_VOICE_DROP
OR
t1.AXS_F_CNT/t1.ATT_CNT >= t2.CRITICAL_VOICE_AXSFAIL
)
THEN 2
WHEN t1.VOICEDATA = 'DATA'
AND
(
t1.CUST_BLK_CNT/t1.ATT_CNT >= t2.CRITICAL_DATA_BLOCK
OR
t1.DRP_CALL_CNT/t1.ATT_CNT >= t2.CRITICAL_DATA_DROP
OR
t1.AXS_F_CNT/t1.ATT_CNT >= t2.CRITICAL_DATA_AXSFAIL
)
THEN 2
ELSE 0
END MAJORCRITICAL
FROM DS3R_FH_ALL_TRIGGER_VIEW t1
INNER JOIN
ZDMSN.DS3R_1XRTT_TRIGGERS_THRESHOLD t2
ON
t1.BSM_NM = t2.BSC_NM
AND
t1.TECHNOLOGY = t2.TECHNOLOGY
WHERE t1.BSM_NM = 'ARL1' and t1.D_DTM = (SELECT MAX(D_DTM) FROM DS3R_FH_1XRTT_BTS_LVL_KPI WHERE BSM_NM = 'ARL1')"
$data_set = new-object system.data.dataset
$adapter = new-object system.data.oracleclient.oracledataadapter ($Query, $Connection)
[void] $adapter.Fill($data_set)
$table = new-object system.data.datatable
$table = $data_set.Tables[0]
$bsmNM = $data_set.Tables[0].Rows[0].BSM_NM
$maxDT = $data_set.Tables[0].Rows[0].MAXDATETIME
$majorC = $data_set.Tables[0].Rows[0].MAJORCRITICAL
$table | Select MAJORCRITICAL
{
if ($majorC -match "*2*" -and $majorC -match "*1*")
if ($majorC -match "*1*" )
if ($majorC -match "*2*")
结果是这样回来的:
它没有错误,但它似乎没有做我想做的事。如果 MAJORCRITICAL 列中的任何行的值为 1,我希望它执行第二个 if 语句,如果一行中有 1,另一行有 2,我希望它执行第一个 if陈述。代码运行,但 if 语句没有运行......