2011-05-16 718 views
2

[運行DB2 UDB版本9]爲什麼這條SQL語句的工作SQLCODE:-420,SQLSTATE:22018,則sqlerrmc:BIGINT

SELECT 
     CASE 
     WHEN A.DAILYDOWNLOADSIZE is null THEN 0 
    else bigint(A.DAILYDOWNLOADSIZE) 
     END "DAILYDOWNLOADSIZE", 
     CASE 
     WHEN A.DAILYDOWNLOADTIME is null THEN 0 
    else bigint(A.DAILYDOWNLOADTIME) 
     END "DAILYDOWNLOADTIME" 
FROM 
EDMPROD.MQT_STB_FACTS A 

...當這一個不

SELECT DISTINCT 
bigint(A.CAMID) AS "CAMID", 
bigint(A.RID) AS "RID", 
A.SOFTWAREVERSION, 
A.MODELNUMBER, 
A.MANUFACTURERID, 
A.MODDATE, 
A.POSTTIME, 
A.DELIVERYMETHOD, 
bigint(A.UPTIME) AS "UPTIME", 
bigint(A.NUMBEROFRESETSSINCELASTSWDL) AS "NUMBEROFRESETSSINCELASTSWDL", 
bigint(A.NUMBEROFSEARCHSIGNALOSDTUNER1) AS "NUMBEROFSEARCHSIGNALOSDTUNER1", 
bigint(A.NUMBEROFSEARCHSIGNALOSDTUNER2) AS "NUMBEROFSEARCHSIGNALOSDTUNER2", 
bigint(A.NUMBEROFUSERDISKREFORMATS) AS "NUMBEROFUSERDISKREFORMATS", 
bigint(A.NUMBEROFSYSTEMDISKREFORMATS) AS "NUMBEROFSYSTEMDISKREFORMATS", 
bigint(A.NUMBEROFRECOVEREDDISKERRORS) AS "NUMBEROFRECOVEREDDISKERRORS", 
IPINFO, 
     CASE 
     WHEN A.DAILYDOWNLOADSIZE is null THEN 0 
    else bigint(A.DAILYDOWNLOADSIZE) 
     END "DAILYDOWNLOADSIZE", 
     CASE 
     WHEN A.DAILYDOWNLOADTIME is null THEN 0 
    else bigint(A.DAILYDOWNLOADTIME) 
     END "DAILYDOWNLOADTIME", 
bigint(A.TOTALNUMBEROFDOWNLOADSSTARTED) AS "TOTALNUMBEROFDOWNLOADSSTARTED", 
bigint(A.TOTALNUMOFCOMPLETEDDLS) AS "TOTALNUMOFCOMPLETEDDLS", 
CURRENT_DATE AS "LOAD_DATE" 
FROM 
EDMPROD.MQT_STB_FACTS A 

出現錯誤SQL0420N在 函數「BIGINT」的字符串參數中找到無效字符。 SQLSTATE = 22018

通過疑難解答查詢,我確認罪魁禍首是兩列DAILYDOWNLOADSIZE和DAILYDOWNLOADTIME。兩者都必須從角色(15)鑄造到bigint。

什麼是第二個SQL語句不工作???

回答

1

我對此失去了很多想法,所以我在暫存表(EDMPROD.MQT_STB_FACTS)中做了一個簡單的更改。

不是將字符串輸入爲字符,而是將它們轉換爲bigint,我放棄並重新創建了我的表,其數據類型設置爲BIGINT(8)。

我從我的SQL語句中刪除了鑄件,錯誤消失了。

去圖..........

+0

這不是一個優雅的解決方案。我有同樣的問題,我無法修復它。你有沒有找到另一種方式? – deltascience 2015-03-12 14:12:04

+0

在數據庫中使用適當的數據類型是我認爲優雅的,所以我們不得不不同意這一點。使用適當的數據類型是一種好的做法。 – 2017-07-20 13:05:06

相關問題