【问题标题】:PL/SQL numeric or value error: number precision too largePL/SQL 数值或数值错误:数值精度太大
【发布时间】:2012-02-19 05:33:01
【问题描述】:

我正在尝试运行一个 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:

【问题讨论】:

    标签: sql oracle plsql oracle10g


    【解决方案1】:

    尝试将shipping number(2,2) 更改为shipping number(4,2)

    (2,2) 基本上是说你想要 2 位数字,其中 2 位在小数点后。所以你的值范围是 0 到 0.99。您真正想要的是“4 位,其中 2 位在小数点后”,范围从 0 到 99.99。

    【讨论】:

    • 谢谢,我在想 MySQL,逗号前的数字是小数点左边的位数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 2014-06-13
    相关资源
    最近更新 更多