簡體   English   中英

不同的數據庫連接可以更新 Oracle 中的同一事務嗎?

[英]Can different DB connections update the same transaction in Oracle?

我想我知道這個問題的答案,但值得一試......

我有一大塊 plsql。 這一切都包含在一筆交易中。 我想將其中的一部分遷移到內部 web 服務(mvc .net / 實體)。

但是當然事務沒有提交,所以服務不能更新它想要的記錄。

如果調用服務的 plsql 可以將事務、事務名稱、上下文、連接、某些內容傳遞給服務並且服務可以返回它以進行進一步更改,那肯定會很棒。

實際上,事務從 .net/wpf 開始,到 plsql 並在 wfp 中返回和提交。 So the idea would be to start a transaction in wpf, go to plsql, which calls a service, returns to plsql and then to wpf and commit. We could break the plsql into two pieces so .net could call the plsql, the service and then resume the transaction in plsql and commit later in .net.

我有類似的要求,但我正在更新多個數據庫,並且需要一個事務來提交或回滾適當的所有內容。 我最終使用了System.Transactions命名空間並創建了一個TransactionScope 我必須從我的 Oracle 驅動程序安裝一個組件,但我很確定這就是所需要的。 這將允許您從 WPF 解決方案控制事務並調用所需的任何內容。

沒有“回滾”語句,不調用Complete()方法自然會在 using 語句結束時回滾事務。

using (var trans = new TransactionScope(TransactionScopeOption.RequiresNew))
{
    var cn  = new OracleConnection();
    // perform PL/SQL

    if (success())
    {
        // this is the "Commit"
        trans.Complete();
    }
}

有關詳細信息,請參閱官方文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM