Oracle:数字或值错误

时间:2011-11-23 10:50:59

标签: java oracle

我从我的java代码调用一个函数,我得到了这个异常。我检查了所有数据类型以及我能想到的其他所有内容,但我仍然遇到了这个例外。

  

java.sql.SQLException:ORA-06502:PL / SQL:数值或值错误:   字符到数字转换错误

if (rs.next()) {
                String originalOrderNature = rs.getString("ORDER_NATURE");
                String stExCode = rs.getString("ST_EX_CODE");
                long orderNumber = rs.getLong("ORDER_NUMBER");
                String client_code = rs.getString("CLIENT_CODE");
                String st_ex_code = rs.getString("ST_EX_CODE");
                String isin = rs.getString("ISIN");
                String symbol = rs.getString("SYMBOL");
                String market_type = rs.getString("MARKET_TYPE");
                String buy_or_sell = rs.getString("BUY_OR_SELL");
                int volume = rs.getInt("VOLUME");
                float rate_limit = rs.getFloat("RATE_LIMIT");
                String order_nature = rs.getString("ORDER_NATURE");
                Date valid_till = rs.getDate("VALID_TILL");
                String order_status_id = rs.getString("ORDER_STATUS_ID");
                aryMarginParam.add(0, originalOrderNature);
                aryMarginParam.add(1, stExCode);
                aryMarginParam.add(2, orderNumber);
                aryMarginParam.add(3, client_code);
                aryMarginParam.add(4, st_ex_code);
                aryMarginParam.add(5, isin);
                aryMarginParam.add(6, symbol);
                aryMarginParam.add(7, market_type);
                aryMarginParam.add(8, buy_or_sell);
                aryMarginParam.add(9, volume);
                aryMarginParam.add(10, rate_limit);
                aryMarginParam.add(11, order_nature);
                aryMarginParam.add(12, valid_till);
                aryMarginParam.add(13, order_status_id);
            }

在这个函数中,我传递了这个arrayList

String statement = "BEGIN ? := abc(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?); END;";

    Object[] in = new Object[13];
    int[] out = new int[2];
    String OriginalOrderNature = (String) arrVerifyMargin.get(0);
    String stExCode = (String) arrVerifyMargin.get(1);
    long orderNumber = (Long) arrVerifyMargin.get(2);
    String client_code = (String) arrVerifyMargin.get(3);
    String st_ex_code = (String) arrVerifyMargin.get(4);
    String isin = (String) arrVerifyMargin.get(5);
    String symbol = (String) arrVerifyMargin.get(6);
    String market_type = (String) arrVerifyMargin.get(7);
    String buy_or_sell = (String) arrVerifyMargin.get(8);
    int volume = (Integer) arrVerifyMargin.get(9);
    float rate_limit = (Float) arrVerifyMargin.get(10);
    String order_nature = (String) arrVerifyMargin.get(11);
    Date valid_till = (Date) arrVerifyMargin.get(12);
    String order_status_id = (String) arrVerifyMargin.get(13);
    int modifyy = modify;   
    //float float_volume = (float)volume;
    System.out.println(OriginalOrderNature + " " + stExCode);

    out[0] = Types.VARCHAR;
    in[0] = orderNumber;
    in[1] = client_code;
    in[2] = st_ex_code;
    in[3] = isin;
    in[4] = symbol;
    in[5] = market_type;
    in[6] = buy_or_sell;
    in[7] = volume;
    in[8] = rate_limit;
    in[9] = order_nature;
    in[10] = valid_till;
    in[11] = order_status_id;
    in[12] = modifyy;
    out[1] = Types.VARCHAR;
    String orderNature = (DAOHelper.call(statement, in, out))[1].toString();
    return orderNature;

2 个答案:

答案 0 :(得分:4)

错误告诉你问题是什么。由于某些原因,PL / SQL正在尝试将字符数据转换为数字,但它不能。

您需要相信错误消息,并尝试找出为什么问题正在发生;例如这些人物是什么以及为什么他们不会转换。

我不是PL / SQL专家,但您需要考虑以下事项:

  • 正在转换的字符串中的非数字字符
  • 领先或尾随空格,
  • 用户输入的“,”等,
  • 如果目标类型是整数
  • ,则为假小数点 如果目标类型是浮点类型,则
  • 多个小数点等
  • 目标类型大小的输入数字太多

其中一些可能导致不同的错误,但绝对是上述中的多个可能导致该错误消息的情况。

答案 1 :(得分:0)

在这一行:

String statement = "BEGIN ? := abc(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?); END;"; 

您不能在BEGIN之后使用占位符(?)。