2009-09-28 330 views
0

我有以下的oracle語句給編譯錯誤。oracle語句編譯錯誤

v_percent_deceased_households := CASE 
WHEN NVL(v_total_households, 0) > 0 THEN 
    (CAST(NVL(v_deceased_households_count, 0) AS FLOAT(53)) 
    /
    CAST(NVL(v_total_households, 0) AS FLOAT(53))) * 100 
    ELSE 0 
     END; 

錯誤是:

錯誤:

PLS-00103: Encountered the symbol "(" when expecting one of the following:.) @ % 
     The symbol ")" was substituted for "(" to continue. 
Line: 317 
Text: (CAST(NVL(v_deceased_households_count, 0) AS FLOAT(53))/CAST(NVL(v_total_households, 0) AS FLOAT(53))) * 100 

Error: PLS-00103: Encountered the symbol "(" when expecting one of the following:.) @ % 
Line: 317 
Text: (CAST(NVL(v_deceased_households_count, 0) AS FLOAT(53))/CAST(NVL(v_total_households, 0) AS FLOAT(53))) * 100 

我似乎無法解決這個語法錯誤..

回答

0

爲什麼CAST(... AS FLOAT(53)) ?爲什麼不只是:

v_percent_deceased_households := CASE 
WHEN v_total_households > 0 THEN 
    (NVL(v_deceased_households_count, 0)/v_total_households) * 100 
    ELSE 0 
     END; 

(我刪除了一些冗餘的NVLs)。

0

相信CAST具有在選擇要使用的或 '選擇進入' 例如 選擇流延('22 -Aug-2003' 爲VARCHAR2(30))從雙 ;

或 select cast(v_deceased_households_count AS float)into myfloat from dual;