Home > Net >  OracleCommand normally inserted to delete, but data modification is not successful?
OracleCommand normally inserted to delete, but data modification is not successful?

Time:11-24


//OracleCommand recent data modification is not successful, I suspect that there is no call before hand to commit the transaction;
//after the change to manual commit the transaction, SQL and parameters are not changed, the trial found two days can modify the data normally, but appear again two days later, data modification is not successful;
//I see the Internet blogger also reflects the change data, add parameter order problem, there is no order, but before that the code can run normally;
//this code before don't have any problem, is can't modify the data in the past two days, but the insert data can be

Public static int QueryCarton (string TXTBarcode, string g_sLoginUserID, string mesdb, string fac, string location="")
{
String SQL;
Var para=new List (a);
If (string. IsNullOrWhiteSpace (location))
{
SQL=@ "UPDATE WMSUSER. INVENTORY_COMPARE AA
SET COMPARE_STATUS='Y',
AA. OPERATOR_ID=: g_sLoginUserID,
AA OPERATE_TIME=SYSDATE,
AA. REASON='
WHERE AA. CARTON_NO=: TXTBarcode
AND AA. MESDB=: MESDB
AND AA. FAC="FAC";
}
The else
{
SQL=@ "UPDATE WMSUSER. INVENTORY_COMPARE AA
SET COMPARE_STATUS='Y',
AA. OPERATOR_ID=: g_sLoginUserID,
AA OPERATE_TIME=SYSDATE,
AA. REASON=",
AA. LOCATION_ID,=: LOCATION_ID,
WHERE AA. CARTON_NO=: TXTBarcode
AND AA. MESDB=: MESDB
AND AA. FAC="FAC";
Para. Add (new OracleParameter (" : the LOCATION_ID, ", the location));
}

Para. Add (new OracleParameter (" : "TXTBarcode TXTBarcode));
Para. Add (new OracleParameter (" : "g_sLoginUserID g_sLoginUserID));
Para. Add (new OracleParameter (" : "MESDB MESDB));
Para. Add (new OracleParameter (" : the FAC ", FAC));
Return ExecuteNonQueryForTransaction (PWSDB, SQL, para. ToArray ());
}

Private static ExecuteResult ExecuteNonQueryForTransaction (string SQL, List Para)
{
Var exeRes=new ExecuteResult ();
If (string. IsNullOrWhiteSpace (SQL)) {return exeRes; }
Try
{
ExeRes=oracleHelper. BeginTransaction ();
if (! ExeRes. Status) {return exeRes; }
ExeRes=oracleHelper. ExecuteNonQueryForTransaction (SQL, para);
If (exeRes Status) {oracleHelper.Com MIT (); }
The else {oracleHelper. The Rollback (); }
}
The catch (Exception ex)
{
OracleHelper. The Rollback ();
ExeRes. Status=false;
ExeRes. Message=ex. The Message;
}
The finally
{
OracleHelper. EndTransaction ();
}
Return exeRes;
}

Public ExecuteResult ExecuteNonQueryForTransaction (string SQL, params OracleParameter [] ¶s)
{
ExecuteResult execRes=new ExecuteResult ();

Try
{
SQL=ProcessSqlCommandText (SQL);

Int result=0;
Using (var. CMD=oracleConnection CreateCommand ())
{
CMD. BindByName=true;
Cmd.Com mandText=SQL;
Cmd.Com mandType=CommandType. Text;
CMD. The Parameters. AddRange (¶s);
CMD. Transaction=oracleTransaction;
Result=CMD. ExecuteNonQuery ();
}
ExecRes. Status=result & gt; 0;
ExecRes. Anything=the result;
}
The catch (Exception ex)
{
ExecRes. Status=false;
ExecRes. Message=ex. The Message;
}

Return execRes;
}

CodePudding user response:

Modified to track mode, line by line to see the results, in order to more accurate positioning error,

CodePudding user response:

This code is sometimes tried and can modify the data normally today, so I wonder, sometimes can normal modification, sometimes with 2-3 w data without modify success;
Modified with addition of logging, return status to true, insert the Y, false is N, two days before the query log data is Y, but the data is not modified success;
This code to modify the article 10-20 w data every afternoon, I didn't add this watch index, if without adding indexes, modify the data, the full table is locked? With the index, the single row is locked?
  •  Tags:  
  • C#
  • Related