UNPIVOT returns db link 上的错误结果

UNPIVOT returns wrong results over db link

我对实现指向远程 table 的 UNPIVOT 的查询有疑问。出于某种原因,它 returns 我的结果是空的,而实际上数据存在(附加查询向下)。

我意识到问题可能是Oracle版本不兼容,虽然我不确定。

其他人也遇到过这种情况吗?

有什么解决办法吗?

查询:

` WITH TABLA1_RAW AS (SELECT   /*MATERIALIZE*/
                            a.fecha,
                            A.MIB_PLATAFORM,
                            A.RE_IP,
                            A.PATH_OID,
                            A.MIB_SECTION,
                            A.MIB_TYPE,
                            A.TYPE_VALOR,
                            A.VALOR,
                            INSTR(PATH_OID, '.', -1)                                            ULTIMO_PUNTO,
                            INSTR(SUBSTR(PATH_OID, 1, INSTR(PATH_OID, '.', -1) -1), '.', -1)    PENULTIMO_PUNTO
                    FROM CALIDAD@PRUEBA.WORLD A
                    WHERE FECHA BETWEEN TO_DATE('22.01.2019 00','DD.MM.YYYY HH24')
                                    AND TO_DATE('22.01.2019 01','DD.MM.YYYY HH24') + (3599/86400)
                          AND A.MIB_PLATAFORM = 'SDWAN'
                    ORDER BY FECHA),
      TABLA2_RAW AS (SELECT
                            FECHA,
                            MIB_PLATAFORM,
                            RE_IP,
                            PATH_OID,
                            MIB_SECTION,
                            MIB_TYPE,
                            TYPE_VALOR,
                            SUBSTR(PATH_OID, 1, ULTIMO_PUNTO - 1)                                                    PATH_MIB,
                            SUBSTR(PATH_OID, ULTIMO_PUNTO + 1, PENULTIMO_PUNTO - 1)                                  INSTANCIA,
                            VALOR,
                            NVL(LAG(VALOR, 1) OVER(PARTITION BY MIB_PLATAFORM,MIB_TYPE,MIB_SECTION,RE_IP,PATH_OID
                                              ORDER BY FECHA), VALOR)                                                 L_VALOR
                     FROM TABLA1_RAW),
     TABLE_RAW AS (SELECT /*MATERIALIZE*/
                          FECHA,
                          MIB_PLATAFORM,
                          RE_IP,
                          PATH_OID,
                          MIB_SECTION,
                          MIB_TYPE,
                          TYPE_VALOR,
                          PATH_MIB,
                          INSTANCIA,
                          VALOR,
                          l_valor,
                          CASE WHEN TYPE_VALOR = 'Counter32'
                                THEN NVL(DECODE(L_VALOR, 0, 0, CASE WHEN L_VALOR > VALOR
                                   THEN CASE WHEN (POWER(2, 32) + VALOR - L_VALOR)  > POWER(2, 60)
                                      THEN 0
                                      ELSE (POWER(2, 32) + VALOR - L_VALOR)
                                      END
                                   ELSE DECODE(L_VALOR, 0, 0, (VALOR - L_VALOR))
                                   END), 0)
                                END                                                                   N_VALOR
                   FROM TABLA2_RAW
                   WHERE PATH_MIB NOT IN ('1')),
     TABLA1_HOUR AS (SELECT FECHA,
                                  --(SELECT TO_CHAR(TRUNC(FECHA,'HH24'),'DD.MM.YYYY HH24')                FECHA,
                                                                                                        RE_IP,
                                                                                                        INSTANCIA,
                            ROUND(AVG(DECODE(PATH_MIB,'1',VALOR)))           CPU_LOAD,
                            ROUND(AVG(DECODE(PATH_MIB,'1',VALOR)))          MEMORY_AVAILABLE,
                            ROUND(AVG(DECODE(PATH_MIB,'1',VALOR)))           MEMORY_USED,
                            ROUND(AVG(DECODE(PATH_MIB,'1',VALOR)))   FLASH_CAPACITY,
                            ROUND(AVG(DECODE(PATH_MIB,'1',VALOR)))   FLASH_USED,
                            ROUND(AVG(DECODE(PATH_MIB,'1',VALOR)))       CONECTIONS,
                            ROUND(AVG(DECODE(PATH_MIB,'1',N_VALOR)))                 TRAFICO_ENTRANTE_KB
                     FROM TABLE_RAW
                     GROUP BY FECHA,--TO_CHAR(TRUNC(FECHA,'HH24'),'DD.MM.YYYY HH24'),
                              RE_IP,
                              INSTANCIA,
                              DECODE(PATH_MIB,'',VALOR)
                    ),
     TABLE_HOUR AS(SELECT                                                         FECHA,
                                                                                  RE_IP,
                                                                                  INSTANCIA,
                                                                                  CPU_LOAD,
                     ROUND(MEMORY_USED/DECODE(MEMORY_USED+MEMORY_AVAILABLE,
                     0,1,MEMORY_USED+MEMORY_AVAILABLE),2)*100                     MEMORY_UTILIZATION,
                                                                                  MEMORY_AVAILABLE,
                                                                                  MEMORY_USED,
                     ROUND(FLASH_USED/DECODE(FLASH_CAPACITY,
                     0,1,FLASH_CAPACITY),2)*100                                   FLASH_UTILIZATION,
                                                                                  FLASH_CAPACITY,
                                                                                  FLASH_USED,
                                                                                  CONECTIONS,
                                                                                  TRAFICO_ENTRANTE_KB
                   FROM TABLA1_HOUR
                  )
SELECT FECHA,
       RE_IP,
       INSTANCIA,
       NOMBRE_KPI,
        VALOR_KPI
FROM  TABLE_HOUR
UNPIVOT INCLUDE NULLS
(VALOR_KPI FOR (NOMBRE_KPI) IN
  (CPU_LOAD                AS  'CPU_LOAD',
   MEMORY_UTILIZATION      AS  'MEMORY_UTILIZATION',
   MEMORY_AVAILABLE        AS  'MEMORY_AVAILABLE',
   MEMORY_USED             AS  'MEMORY_USED',
   FLASH_UTILIZATION       AS  'FLASH_UTILIZATION',
   FLASH_CAPACITY          AS  'FLASH_CAPACITY',
   FLASH_USED              AS  'FLASH_USED',
   CONECTIONS              AS  'CONECTIONS',
   TRAFICO_ENTRANTE_KB     AS  'TRAFICO_ENTRANTE_KB'))`

似乎是已知错误 [Doc ID 2370554.1