1
我正嘗試使用c#更新oracle表記錄。當我執行我的代碼SoapFault時 - faultcode:'a:InternalServiceFault'faultstring:'ORA-01438:值大於指定精度允許的此列'faultactor:'null'detail:org.kxml2.kdom時出現此錯誤。節點@ 99c0b9c。錯誤:'ORA-01438:值大於該列所允許的指定精度'faultactor:'null'詳細信息:[email protected]
這是我用我的服務端代碼:
[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;
}
能否請你幫
什麼是'CustomObjectS'的定義是什麼? – Richard
'num'和'num2'的數據類型(在數據庫中)是什麼? – mjwills
它們的類型是數字 –