错误:'ORA-01438:大于此列允许的指定精度的值'faultactor:'null'详细信息:org.kxml2.kdom.Node@99c0b9c

时间:2017-10-07 08:07:28

标签: c# oracle

我正在尝试使用c#更新oracle表记录。当我执行我的代码SoapFault时,我收到此错误 - faultcode:'a:InternalServiceFault'faultstring:'ORA-01438:大于此列允许的指定精度的值'faultactor:'null'详细信息:org.kxml2.kdom。节点@ 99c0b9c。

这是我在服务方面使用的代码:

[OperationContract]

public int pushData(string CustomObjects)
{

  List<CustomObject> myDeserializedObjList = (List<CustomObject>)Newtonsoft.Json.JsonConvert.DeserializeObject(CustomObjects, 
  typeof(List<CustomObject>));
  string constr = "my connection string";
  int rowid = 0;
  using(OracleConnection con = new OracleConnection(constr)){

  con.Open();
  OracleCommand cmd = new OracleCommand();
  cmd.Connection = con;
  cmd.CommandType = CommandType.Text;

   foreach (CustomObject element in myDeserializedObjList)
   {

      int num = element.num;

      string mydate = element.mydate;

      long num2 = element.num2;

      string user = element.user;


      string sqlStatement= "UPDATE CustomObjectS SET  num = :num, 
      mydate=:to_date(:mydate, 'YYYY/MM/DD HH:MI:SS'), num2=:num2, user=:user  WHERE num =:num";
      OracleTransaction myTrans;

      // Start a local transaction
      myTrans = con.BeginTransaction();
      // Assign transaction object for a pending local transaction
      cmd.Transaction = myTrans;
      cmd.CommandText=sqlStatement;
      cmd.Parameters.Add(new OracleParameter("num", num));
      cmd.Parameters.Add(new OracleParameter("user", user));
      cmd.Parameters.Add(new OracleParameter("num2", num2));
      cmd.Parameters.Add(new OracleParameter("mydate", mydate));
      cmd.Parameters[3].Value = mydate;


              rowid= cmd.ExecuteNonQuery();

              myTrans.Commit();



      }


      }


  return rowid;

      }

你能帮忙吗

1 个答案:

答案 0 :(得分:0)

  

ORA-01438:大于指定精度的值允许这样做   柱

在INSERT或UPDATE语句期间出现此错误。这意味着,您尝试为列分配的值超出了为此列定义的精度。

一个简单的例子:

CREATE TABLE abc1(
  x NUMBER(5)
);


INSERT INTO abc1( x ) values (123456 );
ORA-01438: value larger than specified precision allowed for this column


INSERT INTO abc1( x ) values (12345 ); 
1 row inserted.

你能做什么:

  • 为列分配较小的精度值(不要分配如此大的数字)。
  • 更改表的定义以允许列中的更高精度数。这可以使用ALTER TABLE语句完成。
ALTER TABLE abc1 MODIFY x NUMBER(10);
Table ABC1 altered.

INSERT INTO abc1( x ) values (123456 );
1 row inserted.