2012-10-11 85 views
-2

我在下面的選擇查詢中出現錯誤。這是錯誤我收到:ORA-00905:選擇語句中缺少關鍵字錯誤

ORA-00905:缺少關鍵字

誰能幫助?

SELECT ni.node_installation_id,ni.customer_node_id,ni.customer_id,c.brand_name_1,substr(nitr.name,1,instr(nitr.name, ' ')-1) as node_inst_type 
    from node_installation ni , customer c , node_inst_type_release nitr 
    where (Case 
      WHEN ni.arne_timestamp is null THEN (case 
                when ni.arne_flag ='I' then ni.arne_flag ='I' 
                END) 
    else (trunc(sysdate) - trunc(ni.arne_timestamp) >= 60) 
     end)  
and ni.customer_id = c.customer_id 
and ni.node_inst_type_release_id = nitr.node_inst_type_release_id 
and ni.no_of_collection_node_missed >= 4 
and c.customer_id =90; 
+0

請詳細介紹一下您正在開發的項目。你已經試過了什麼? –

+0

檢查您的ID的名稱,它與數據庫的預定義ID匹配... 我正在進一步分析它。 –

回答

1

也許問題出在case

( 
    case 
    when ni.arne_flag ='I' 
     then ni.arne_flag ='I' 
    END 
) 

我覺得條件是完全錯誤的。嘗試將其更改爲:

((ni.arne_timestamp is null and ni.arne_flag ='I') 
or 
(trunc(sysdate) - trunc(ni.arne_timestamp) >= 60)) 

如下:

SELECT ni.node_installation_id, 
      ni.customer_node_id, 
      ni.customer_id, 
      c.brand_name_1, 
      substr(nitr.name,1,instr(nitr.name, ' ')-1) as node_inst_type 
    from node_installation ni , 
      customer c , 
      node_inst_type_release nitr 
    where ((ni.arne_timestamp is null and ni.arne_flag ='I') 
      or 
      (trunc(sysdate) - trunc(ni.arne_timestamp) >= 60))  
    and ni.customer_id = c.customer_id 
    and ni.node_inst_type_release_id = nitr.node_inst_type_release_id 
    and ni.no_of_collection_node_missed >= 4 
    and c.customer_id =90; 
0

你內心的CASE語句看起來我錯了,雖然我不是100%,爲什麼是語法不正確:

CASE 
     WHEN ni.arne_flag = 'I' THEN **ni.arne_flag = 'I'** END 

'THEN'之後的表達應該是一個值,我想,但無論如何它是多餘的。