2 // OciTransactionHandle.cs
4 // Part of managed C#/.NET library System.Data.OracleClient.dll
6 // Part of the Mono class libraries at
7 // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
9 // Assembly: System.Data.OracleClient.dll
10 // Namespace: System.Data.OracleClient.Oci
13 // Tim Coleman <tim@timcoleman.com>
15 // Copyright (C) Tim Coleman, 2003
19 using System
.Runtime
.InteropServices
;
21 namespace System
.Data
.OracleClient
.Oci
{
22 internal sealed class OciTransactionHandle
: OciHandle
, IDisposable
26 bool disposed
= false;
27 OciErrorHandle errorHandle
;
28 OciServiceHandle serviceHandle
;
34 public OciTransactionHandle (OciHandle parent
, IntPtr handle
)
35 : base (OciHandleType
.Transaction
, parent
, handle
)
39 #endregion // Constructors
43 public OciErrorHandle ErrorHandle
{
44 get { return errorHandle; }
45 set { errorHandle = value; }
48 public OciServiceHandle Service
{
49 get { return serviceHandle; }
50 set { serviceHandle = value; }
53 #endregion // Properties
57 public void AttachToServiceContext ()
60 status
= OciCalls
.OCIAttrSet (Service
,
61 OciHandleType
.Service
,
64 OciAttributeType
.Transaction
,
67 OciErrorInfo info
= ErrorHandle
.HandleError ();
68 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
72 public void DetachFromServiceContext ()
75 status
= OciCalls
.OCIAttrSet (Service
,
76 OciHandleType
.Service
,
79 OciAttributeType
.Transaction
,
83 OciErrorInfo info
= ErrorHandle
.HandleError ();
84 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
92 AttachToServiceContext ();
94 status
= OciCalls
.OCITransStart (Service
,
97 OciTransactionFlags
.New
);
100 OciErrorInfo info
= ErrorHandle
.HandleError ();
101 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
105 public void Commit ()
108 AttachToServiceContext ();
110 status
= OciCalls
.OCITransCommit (Service
, ErrorHandle
, 0);
114 OciErrorInfo info
= ErrorHandle
.HandleError ();
115 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
119 DetachFromServiceContext ();
123 protected override void Dispose (bool disposing
)
127 base.Dispose (disposing
);
131 public void Rollback ()
135 AttachToServiceContext ();
136 status
= OciCalls
.OCITransRollback (Service
, ErrorHandle
, 0);
139 OciErrorInfo info
= ErrorHandle
.HandleError ();
140 throw new OracleException (info
.ErrorCode
, info
.ErrorMessage
);
144 DetachFromServiceContext ();
148 #endregion // Methods