0

我有以下在 powershell 中运行的查询:

$Query = "SELECT 
             t1.BSM_NM
            ,t1.D_DTM AS MAXDATETIME
            ,CASE
                WHEN SUM(t1.V_CUST_BLK_CNT)/SUM(t1.V_ATT_CNT) >= MAX(t2.MAJOR_VOICE_BLOCK) AND SUM(t1.V_CUST_BLK_CNT)/SUM(t1.V_ATT_CNT) < MAX(t2.CRITICAL_VOICE_BLOCK)
                     OR
                     SUM(t1.V_DRP_CALL_CNT)/SUM(t1.V_ATT_CNT) >= MAX(t2.MAJOR_VOICE_DROP) AND SUM(t1.V_DRP_CALL_CNT)/SUM(t1.V_ATT_CNT) < MAX(t2.CRITICAL_VOICE_DROP)
                     OR
                     SUM(t1.V_AXS_F_CNT)/SUM(t1.V_ATT_CNT) >= MAX(t2.MAJOR_VOICE_AXSFAIL) AND SUM(t1.V_AXS_F_CNT)/SUM(t1.V_ATT_CNT) < MAX(t2.CRITICAL_VOICE_AXSFAIL)
                THEN 1
                WHEN SUM(t1.V_CUST_BLK_CNT)/SUM(t1.V_ATT_CNT) >= MAX(t2.CRITICAL_VOICE_BLOCK)
                     OR
                     SUM(t1.V_DRP_CALL_CNT)/SUM(t1.V_ATT_CNT) >= MAX(t2.CRITICAL_VOICE_DROP)
                     OR
                     SUM(t1.V_AXS_F_CNT)/SUM(t1.V_ATT_CNT) >= MAX(t2.CRITICAL_VOICE_AXSFAIL)
                THEN 2
                ELSE 0
             END MAJORCRITICAL
            FROM DMSN.DS3R_FH_1XRTT_BTS_LVL_KPI t1
            INNER JOIN
            ZDMSN.DS3R_1XRTT_TRIGGERS_THRESHOLD t2
            ON
            t1.BSM_NM = t2.BSC_NM
            WHERE t1.BSM_NM = 'ARL1' and t1.D_DTM = (SELECT MAX(D_DTM) FROM DS3R_FH_1XRTT_BTS_LVL_KPI WHERE BSM_NM = 'ARL1')
            GROUP BY
            t1.BSM_NM, t1.D_DTM"      

$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]   

但是我如何将 BSM_NM、MAXDATETIME 和 MAJORCRITICAL 设置为 powershell 中的变量。我想最终在脚本下方的电子邮件中使用它们。

4

1 回答 1

2

对于 1 行试试这个

$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
于 2013-05-22T15:26:18.527 回答