我有一个oracle 10g PL / SQL程序,我正试图运行,
程序
set serveroutput on size 10000;
DECLARE
membership varchar2(1) :='Y';
shipping number(2,2);
quantity number(3) :=0;
BEGIN
if membership = 'Y' then
if quantity <= 3 then
shipping := 3.00;
elsif quantity > 3 and quantity <= 6 then
shipping := 5.00;
elsif quantity > 6 and quantity <= 10 then
shipping := 7.00;
elsif quantity > 10 then
shipping := 9.00;
end if;
elsif membership = 'N' then
if quantity <= 3 then
shipping := 5.00;
elsif quantity > 3 and quantity <= 6 then
shipping := 7.50;
elsif quantity > 6 and quantity <= 10 then
shipping := 10.00;
elsif quantity > 10 then
shipping := 12.00;
end if;
end if;
DBMS_OUTPUT.PUT_LINE(shipping);
END;
我一直在犯的错误。起初我以为这只是因为我将数量分配给数字(3),所以我会与003进行比较,但这也不起作用。
Error report:
ORA-06502: PL/SQL: numeric or value error: number precision too large
ORA-06512: at line 8
06502. 00000 - "PL/SQL: numeric or value error%s"
*Cause:
*Action:
答案 0 :(得分:13)
尝试将shipping number(2,2)
更改为shipping number(4,2)
(2,2)基本上是说你想要2位数,其中2位在小数点后面。所以你的值范围是0到0.99。你真正想要的是“4位数,其中2位在小数点后”,范围从0到99.99。