OciTransactionHandle.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // OciTransactionHandle.cs
  3. //
  4. // Part of managed C#/.NET library System.Data.OracleClient.dll
  5. //
  6. // Part of the Mono class libraries at
  7. // mcs/class/System.Data.OracleClient/System.Data.OracleClient.Oci
  8. //
  9. // Assembly: System.Data.OracleClient.dll
  10. // Namespace: System.Data.OracleClient.Oci
  11. //
  12. // Author:
  13. // Tim Coleman <[email protected]>
  14. //
  15. // Copyright (C) Tim Coleman, 2003
  16. //
  17. using System;
  18. using System.Runtime.InteropServices;
  19. namespace System.Data.OracleClient.Oci {
  20. internal sealed class OciTransactionHandle : OciHandle, IOciHandle, IDisposable
  21. {
  22. #region Fields
  23. OciErrorHandle errorHandle;
  24. OciServiceHandle serviceHandle;
  25. #endregion // Fields
  26. #region Constructors
  27. public OciTransactionHandle (OciEnvironmentHandle environment, IntPtr handle)
  28. : base (OciHandleType.Transaction, environment, handle)
  29. {
  30. }
  31. #endregion // Constructors
  32. #region Properties
  33. public OciErrorHandle ErrorHandle {
  34. get { return errorHandle; }
  35. set { errorHandle = value; }
  36. }
  37. public OciServiceHandle Service {
  38. get { return serviceHandle; }
  39. set { serviceHandle = value; }
  40. }
  41. #endregion // Properties
  42. #region Methods
  43. [DllImport ("oci")]
  44. public static extern int OCITransStart (IntPtr svchp,
  45. IntPtr errhp,
  46. uint timeout,
  47. [MarshalAs (UnmanagedType.U4)] OciTransactionFlags flags);
  48. public void Begin ()
  49. {
  50. int status = 0;
  51. status = OciGlue.OCIAttrSet (Service.Handle,
  52. OciHandleType.Service,
  53. Handle,
  54. 0,
  55. OciAttributeType.Transaction,
  56. ErrorHandle.Handle);
  57. if (status != 0) {
  58. OciErrorInfo info = ErrorHandle.HandleError ();
  59. throw new OracleException (info.ErrorCode, info.ErrorMessage);
  60. }
  61. status = OCITransStart (Service.Handle,
  62. ErrorHandle.Handle,
  63. 60,
  64. OciTransactionFlags.New);
  65. if (status != 0) {
  66. OciErrorInfo info = ErrorHandle.HandleError ();
  67. throw new OracleException (info.ErrorCode, info.ErrorMessage);
  68. }
  69. }
  70. public void Commit ()
  71. {
  72. }
  73. public void Dispose ()
  74. {
  75. Environment.FreeHandle (this);
  76. }
  77. public void Rollback ()
  78. {
  79. }
  80. #endregion // Methods
  81. }
  82. }