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
发生错误。怎么了?我该如何纠正这个问题?
最佳答案
与其使用 REPLACE,不如使用更强大的 REGEXP_REPLACE 函数。 http://www.orafaq.com/wiki/REGEXP_REPLACE
然后您可以使用 TO_NUMBER
函数从字符串中删除任何非数字字符。
在你的情况下它会是这样的:
REGEXP_REPLACE(:P21_TOTAL_PRICE, '[^0-9]+', '');
在这里查看我对几乎完全相同问题的回答:Oracle To_Char function How to handle if it's already a string
关于oracle - 字符到数字转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9074589/