2012-01-31 46 views
2
declare 
    l_tot number := 0; 

begin 
    for i in 1..apex_application.g_f08.count loop 
     l_tot := l_tot + nvl(to_number(apex_application.g_f08(i)),0); 
    end loop; 

if l_tot = nvl(to_number(:P21_TOTAL_PRICE),0) then 
     return true; 
    else 
     return false; 
    end if; 
end; 

得到了與上面的代碼字符到低於誤差數轉換錯誤

ORA-06502: PL/SQL: numeric or value error: character to number conversion error 

發生錯誤與:P21_TOTAL_PRICE。什麼是錯的?我怎樣才能糾正這一點?

+1

你有沒有在價格領域逗號或空格? – Sathya 2012-01-31 05:38:39

+0

@Sathya是的。 ':P21_TOTAL_PRICE'中的值爲'5,500.00' – Bishan 2012-01-31 05:42:10

回答

2

錯誤上升,因爲你代表的數量實際上是一個涉及逗號等。當你把一個TO_NUMBER到一個字符串,甲骨文不能代替逗號。

您可能需要使用replace功能脫光逗號

變化

if l_tot = nvl(to_number(:P21_TOTAL_PRICE),0) then 

if l_tot = nvl(to_number(replace(:P21_TOTAL_PRICE,',','')),0) then