简体   繁体   English

无法使用C#更新Oracle数据库中表的列

[英]Unable to update column of a table in Oracle database using C#

I am trying to update two tables in Oracle database.The first try/catch part works fine, however, the second one does not update penalty_fine column, although I have used the same code. 我正在尝试更新Oracle数据库中的两个表。第一个try / catch部分工作正常,但是,第二个不更新penalty_fine列,尽管我使用了相同的代码。 The query works fine on Toad. 该查询在Toad上运行正常。 I tried to merge them into one try/catch by merging sql queries, but it did not work on the second table. 我尝试通过合并SQL查询将它们合并到一个try / catch中,但它在第二个表上不起作用。

Any help is appreciated. 任何帮助表示赞赏。

Thanks 谢谢

try
{

    OracleCommand command2 = new OracleCommand();

    command2.CommandText = "Update t_payment set amount = :amount + (select amount from t_payment where penalty_order_id = (select id from t_penalty_order where protokol_no = :invoiceNumber)) where penalty_order_id = (select id from t_penalty_order where protokol_no = :invoiceNumber)";

    command2.Parameters.Add(new OracleParameter(@"amount", OracleDbType.Int32)).Value = Convert.ToInt32(request.amount);
    command2.Parameters.Add(new OracleParameter(@"invoiceNumber", OracleDbType.Varchar2, 255)).Value = request.invoiceNumber;

    command2.Connection = connection;

    command2.CommandType = System.Data.CommandType.Text;


    command2.ExecuteNonQuery();


}
catch (Exception e)
{
    completePayment.code = 111;
    completePayment.message = e.Message;
    completePayment.transactionNumber = null;
}




try
{

    OracleCommand command2 = new OracleCommand();

    command2.CommandText = "Update t_penalty_order set penalty_fine = 10 where protokol_no = :invoiceNumber";


    command2.Parameters.Add(new OracleParameter(@"invoiceNumber", OracleDbType.Varchar2, 255)).Value = request.invoiceNumber;

    command2.Connection = connection;

    command2.CommandType = System.Data.CommandType.Text;


    command2.ExecuteNonQuery();


}
catch (Exception e)
{
    completePayment.code = 111;
    completePayment.message = e.Message;
    completePayment.transactionNumber = null;
}

I restarted the remote server and it started working. 我重新启动远程服务器,它开始工作。 Thank you 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM