0
在我的實現中使用的查詢給我帶來了ORA-01722錯誤。以下是查詢。在執行以下查詢時獲取ORA-01722錯誤
select ao.account_oid,ao.website_oid,ob.oid,ob.status_code,pi.oid,pi.render_status,ao.invoiced_date
from acct_order ao,order_basket ob, order_line_item oli,order_line_item_xml olix,project_info pi
where ao.oid = ob.account_order_oid and
ob.oid = oli.order_basket_oid and
oli.oid = olix.order_line_item_oid and
pi.oid = olix.xml_value and
olix.xml_key_code='PROJECT_INFO_OID' and
pi.oid = 10000450011; // this is not working
注意:「olix.xml_value」也可能包含字符串值。
我修改它通過「中的」操作者替換「=」運算符,並試圖,即使如此,它失敗。 但是,如果「in」運算符的no值超過1,那麼它的工作。
select ao.account_oid,ao.website_oid,ob.oid,ob.status_code,pi.oid,pi.render_status,ao.invoiced_date
from acct_order ao,order_basket ob, order_line_item oli,order_line_item_xml olix,project_info pi
where ao.oid = ob.account_order_oid and
ob.oid = oli.order_basket_oid and
oli.oid = olix.order_line_item_oid and
pi.oid = olix.xml_value and
olix.xml_key_code='PROJECT_INFO_OID' and
pi.oid in (10000450011,10000460011); // This is working. One argument to "in" operator is not working.
所以我就SQLDeveloper的解釋,但無法理解它。有人能幫我弄清楚這個問題嗎?當試圖以一字符串轉換爲一個數字,並且該字符串不能被轉換成一個有效的數字發生
pi.oid是數字。我通過將to_char作爲to_char(pi.oid)= olix.xml_value包圍pi.oid來解決它。我的問題爲什麼當我們使用「in」運算符而沒有任何這樣的to_char()轉換時它工作? –
pi.oid in(num1,num2)顯然會起作用,因爲p.oid是一個數字。當只有一個參數時,相等將滿足where子句,當有兩個參數時,它們中的任何數字都滿足where子句。 –