OciServiceHandle service;
OciSessionHandle session;
- // other codes
+ // OCI Return Codes
public const int OCI_DEFAULT = 0;
public const int OCI_SUCCESS = 0;
- public const int OCI_SUCCESS_WITH_INFO = 1;
+ public const int OCI_SUCCESS_WITH_INFO = 1; // Diagnostic or Warning message - call OCIErrorGet
public const int OCI_RESERVED_FOR_INT_USE = 200;
public const int OCI_NO_DATA = 100;
- public const int OCI_ERROR = -1;
+ public const int OCI_ERROR = -1; // use error handle to get error code and description - call OCIErrorGet
public const int OCI_INVALID_HANDLE = -2;
public const int OCI_NEED_DATA = 99;
public const int OCI_STILL_EXECUTING = -3123;
get { return service; }
}
+ public OciServerHandle ServerHandle {
+ get { return server; }
+ }
+
+ public OciSessionHandle SessionHandle {
+ get { return session; }
+ }
+
#endregion // Properties
#region Methods
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
- if (!session.BeginSession (OciCredentialType.RDBMS, OciSessionMode.Default, ErrorHandle)) {
+ if (!session.BeginSession (conInfo.CredentialType, OciSessionMode.Default, ErrorHandle)) {
OciErrorInfo info = error.HandleError ();
Disconnect ();
throw new OracleException (info.ErrorCode, info.ErrorMessage);
}
-
if (!service.SetSession (session)) {
OciErrorInfo info = error.HandleError ();
Disconnect ();
public void Disconnect()
{
- if (session != null)
+ if (session != null) {
+ session.EndSession (error);
session.Dispose ();
- if (server != null)
+ session = null;
+ }
+ if (server != null) {
+ server.Detach (error);
server.Dispose ();
- if (error != null)
+ server = null;
+ }
+ if (error != null) {
error.Dispose ();
- if (service != null)
+ error = null;
+ }
+ if (service != null) {
service.Dispose ();
- if (environment != null)
+ service = null;
+ }
+ if (environment != null) {
environment.Dispose ();
+ environment = null;
+ }
+ }
+
+ public static string ReturnCodeToString (int status)
+ {
+ switch (status) {
+ case OCI_DEFAULT:
+ return "OCI_DEFAULT or OCI_SUCCESS"; // both are zero
+ case OCI_SUCCESS_WITH_INFO:
+ return "OCI_SUCCESS_WITH_INFO";
+ case OCI_RESERVED_FOR_INT_USE:
+ return "OCI_RESERVED_FOR_INT_USE";
+ case OCI_NO_DATA:
+ return "OCI_NO_DATA";
+ case OCI_ERROR:
+ return "OCI_ERROR";
+ case OCI_INVALID_HANDLE:
+ return "OCI_INVALID_HANDLE";
+ case OCI_NEED_DATA:
+ return "OCI_NEED_DATA";
+ case OCI_STILL_EXECUTING:
+ return "OCI_STILL_EXECUTING";
+ case OCI_CONTINUE:
+ return "OCI_CONTINUE";
+ }
+ return "Unknown Error";
}
#endregion // Methods
}
}
+