void DefineChar(int position, OracleConnection connection) { fieldType = typeof(System.String); int maxByteCount = Encoding.UTF8.GetMaxByteCount(definedSize); value = OciCalls.AllocateClear(maxByteCount); ociType = OciDataType.Char; int status = 0; status = OciCalls.OCIDefineByPos(Parent, out handle, ErrorHandle, position + 1, value, maxByteCount, ociType, indicator, rlenp, IntPtr.Zero, 0); OciErrorHandle.ThrowExceptionIfError(ErrorHandle, status); }
internal bool SetCredentialAttributes(OciErrorHandle error) { errorHandle = error; int status; status = OciCalls.OCIAttrSetString(this, OciHandleType.Session, username, (uint)username.Length, OciAttributeType.Username, errorHandle); if (status != 0) { return(false); } status = OciCalls.OCIAttrSetString(this, OciHandleType.Session, password, (uint)password.Length, OciAttributeType.Password, errorHandle); if (status != 0) { return(false); } return(true); }
public bool BeginSession(OciCredentialType credentialType, OciSessionMode mode, OciErrorHandle error) { errorHandle = error; int status; if (credentialType == OciCredentialType.RDBMS) { if (!SetCredentialAttributes(errorHandle)) { return(false); } } status = OciCalls.OCISessionBegin(Service, errorHandle, Handle, credentialType, mode); if (status != 0) { return(false); } begun = true; return(true); }
public void Disconnect() { if (session != null) { session.EndSession(error); session.Dispose(); session = null; } if (server != null) { server.Detach(error); server.Dispose(); server = null; } if (error != null) { error.Dispose(); error = null; } if (service != null) { service.Dispose(); service = null; } if (environment != null) { environment.Dispose(); environment = null; } }
//[MonoTODO ("Only will work with 9i and above. Get it to work for 8i as well.")] internal string GetRowIdToString(OciErrorHandle errorHandle) { string output = String.Empty; int len = 18; // Universal ROWID has a length of 18 int maxByteCount = Encoding.UTF8.GetMaxByteCount(len); IntPtr outputPtr = OciCalls.AllocateClear(maxByteCount); int status = 0; ushort u = (ushort)maxByteCount; status = OCIRowidToChar(Handle, outputPtr, ref u, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && maxByteCount > 0) { object str = Marshal.PtrToStringAnsi(outputPtr, len); if (str != null) { output = String.Copy((string)str); } } return(output); }
internal bool SetCredentialAttributes (OciErrorHandle error) { errorHandle = error; int status; status = OciCalls.OCIAttrSetString (this, OciHandleType.Session, username, (uint) username.Length, OciAttributeType.Username, errorHandle); if (status != 0) return false; status = OciCalls.OCIAttrSetString (this, OciHandleType.Session, password, (uint) password.Length, OciAttributeType.Password, errorHandle); if (status != 0) return false; return true; }
public DateTime GetDateTime(OciHandle handle, OciErrorHandle errorHandle) { short year = 0; byte month = 0; byte day = 0; byte hour = 0; byte min = 0; byte sec = 0; uint fsec = 0; int fs = 0; OciCalls.OCIDateTimeGetDate(handle, errorHandle, this.Handle, out year, out month, out day); OciCalls.OCIDateTimeGetTime(handle, errorHandle, this.Handle, out hour, out min, out sec, out fsec); // a TIMESTAMP can have up to 9 digits of millisecond but DateTime only // can be up to 999. if (fsec > 0) { int fseci = (int)fsec; fs = fseci / 1000000; } return(new DateTime(year, month, day, hour, min, sec, fs)); }
internal string GetAttributeString(OciAttributeType attrType, OciErrorHandle errorHandle) { string output = String.Empty; IntPtr outputPtr = IntPtr.Zero; int outSize; int status = 0; status = OciCalls.OCIAttrGet(Handle, HandleType, out outputPtr, out outSize, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && outSize > 0) { object str = Marshal.PtrToStringAnsi(outputPtr, outSize); if (str != null) { output = String.Copy((string)str); } } return(output); }
public void SetDateTime(OciHandle handle, OciErrorHandle errorHandle, short year, byte month, byte day, byte hour, byte min, byte sec, uint fsec, string timezone) { // Get size of buffer ulong rsize = 0; UIntPtr rsizep = new UIntPtr(rsize); int status = OciCalls.OCIUnicodeToCharSet(handle, null, timezone, ref rsizep); // Fill buffer rsize = rsizep.ToUInt64(); byte[] bytes = new byte[rsize]; if (status == 0 && rsize > 0) { OciCalls.OCIUnicodeToCharSet(handle, bytes, timezone, ref rsizep); } if (fsec > 0) { fsec = fsec * 1000000; } uint timezoneSize = (uint)bytes.Length; OciCalls.OCIDateTimeConstruct(handle, errorHandle, this.Handle, year, month, day, hour, min, sec, fsec, bytes, timezoneSize); //uint valid = 0; //int result = OciCalls.OCIDateTimeCheck (handle, // errorHandle, this.Handle, out valid); }
internal OciRowIdDescriptor GetAttributeRowIdDescriptor(OciErrorHandle errorHandle, OciHandle env) { OciRowIdDescriptor descriptor = null; IntPtr outputPtr = IntPtr.Zero; int outSize = 16; int status = 0; OciAttributeType attrType = OciAttributeType.RowId; outputPtr = OciCalls.AllocateClear(outSize); uint siz = (uint)outSize; status = OCIAttrGetRowIdDesc(Handle, HandleType, outputPtr, ref siz, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && siz > 0) { descriptor = (OciRowIdDescriptor)env.Allocate(OciHandleType.RowId); descriptor.SetHandle(outputPtr); } return(descriptor); }
public int GetYearToMonth(OciHandle handle, OciErrorHandle errorHandle) { int years = 0; int months = 0; OciCalls.OCIIntervalGetYearMonth(handle, errorHandle, out years, out months, this.handle); return((years * 12) + months); }
public void EndSession(OciErrorHandle error) { if (!begun) { return; } OciCalls.OCISessionEnd(Service, error, this, 0); begun = false; }
public bool Attach (string tnsname, OciErrorHandle error) { errorHandle = error; int status = OciCalls.OCIServerAttach (this, error, tnsname, tnsname.Length, 0); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } attached = true; return attached; }
public void Detach (OciErrorHandle error) { if (!attached) return; int status = OciCalls.OCIServerDetach (this, error, 0); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } attached = false; }
public bool Attach(string tnsname, OciErrorHandle error) { errorHandle = error; int status = OciCalls.OCIServerAttach(this, error, tnsname, tnsname.Length, 0); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } attached = true; return(attached); }
public bool BeginSession(OciCredentialType credentialType, OciSessionMode mode, OciErrorHandle error) { errorHandle = error; int status = 0; if (credentialType == OciCredentialType.RDBMS) { status = OciCalls.OCIAttrSetString(this, OciHandleType.Session, username, (uint)username.Length, OciAttributeType.Username, errorHandle); if (status != 0) { return(false); } status = OciCalls.OCIAttrSetString(this, OciHandleType.Session, password, (uint)password.Length, OciAttributeType.Password, errorHandle); if (status != 0) { return(false); } } status = OciCalls.OCISessionBegin(Service, errorHandle, Handle, credentialType, mode); if (status != 0) { return(false); } begun = true; return(true); }
public void Detach(OciErrorHandle error) { if (!attached) { return; } int status = OciCalls.OCIServerDetach(this, error, 0); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } attached = false; }
public TimeSpan GetDayToSecond(OciHandle handle, OciErrorHandle errorHandle) { int days = 0; int hours = 0; int mins = 0; int secs = 0; int fsec = 0; int fs = 0; OciCalls.OCIIntervalGetDaySecond(handle, errorHandle, out days, out hours, out mins, out secs, out fsec, this.handle); if (fsec > 0) { int fseci = (int)fsec; fs = fseci / 1000000; } return(new TimeSpan(days, hours, mins, secs, fs)); }
internal bool ChangePassword (string new_password, OciErrorHandle error) { if (!session.SetCredentialAttributes (error)) return false; byte[] ub = UnicodeToCharSet (session.Username byte[] opb = UnicodeToCharSet (session.Password); byte[] npb = UnicodeToCharSet (new_password); int status = OciCalls.OCIPasswordChange (this, error, ub, ub.Length, opb, opb.Length, npb, npb.Length, OCI_AUTH); if (status == 0) { session.Password = new_password; return true; } return false; }
internal IntPtr GetAttributeIntPtr(OciAttributeType attrType, OciErrorHandle errorHandle) { int status = 0; IntPtr output = IntPtr.Zero; status = OciCalls.OCIAttrGetIntPtr(Handle, HandleType, out output, IntPtr.Zero, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } return(output); }
public bool BeginSession (OciCredentialType credentialType, OciSessionMode mode, OciErrorHandle error) { errorHandle = error; int status = 0; if (credentialType == OciCredentialType.RDBMS) { status = OciCalls.OCIAttrSetString (this, OciHandleType.Session, username, (uint) username.Length, OciAttributeType.Username, errorHandle); if (status != 0) return false; status = OciCalls.OCIAttrSetString (this, OciHandleType.Session, password, (uint) password.Length, OciAttributeType.Password, errorHandle); if (status != 0) return false; } status = OciCalls.OCISessionBegin (Service, errorHandle, Handle, credentialType, mode); if (status != 0) return false; begun = true; return true; }
internal OciRowIdDescriptor GetAttributeRowIdDescriptor (OciErrorHandle errorHandle, OciHandle env) { OciRowIdDescriptor descriptor = null; IntPtr outputPtr = IntPtr.Zero; int outSize = 16; int status = 0; OciAttributeType attrType = OciAttributeType.RowId; outputPtr = OciCalls.AllocateClear (outSize); uint siz = (uint) outSize; status = OCIAttrGetRowIdDesc (Handle, HandleType, outputPtr, ref siz, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && siz > 0) { descriptor = (OciRowIdDescriptor) env.Allocate(OciHandleType.RowId); descriptor.SetHandle (outputPtr); } return descriptor; }
public void CreateConnection (OracleConnectionInfo conInfo) { environment = new OciEnvironmentHandle (OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback); if (environment.Handle == IntPtr.Zero) throw new OracleException (0, "Could not allocate the Oracle environment."); service = (OciServiceHandle) environment.Allocate (OciHandleType.Service); if (service == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } error = (OciErrorHandle) environment.Allocate (OciHandleType.Error); if (error == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } service.ErrorHandle = error; server = (OciServerHandle) environment.Allocate (OciHandleType.Server); if (server == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } session = (OciSessionHandle) environment.Allocate (OciHandleType.Session); if (session == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } session.Username = conInfo.Username; session.Password = conInfo.Password; session.Service = service; if (!server.Attach (conInfo.Database, ErrorHandle)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (!service.SetServer (server)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (!session.BeginSession (OciCredentialType.RDBMS, OciSessionMode.Default, ErrorHandle)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (!service.SetSession (session)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } connected = true; }
public OciErrorInfo HandleError() { OciErrorInfo info = OciErrorHandle.HandleError(this); return(info); }
public void CreateConnection(OracleConnectionInfo conInfo) { environment = new OciEnvironmentHandle(OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback); if (environment.Handle == IntPtr.Zero) { throw new OracleException(0, "Could not allocate the Oracle environment."); } service = (OciServiceHandle)environment.Allocate(OciHandleType.Service); if (service == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } error = (OciErrorHandle)environment.Allocate(OciHandleType.Error); if (error == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } service.ErrorHandle = error; server = (OciServerHandle)environment.Allocate(OciHandleType.Server); if (server == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } session = (OciSessionHandle)environment.Allocate(OciHandleType.Session); if (session == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } session.Username = conInfo.Username; session.Password = conInfo.Password; session.Service = service; if (!server.Attach(conInfo.Database, ErrorHandle)) { OciErrorInfo info = error.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (!service.SetServer(server)) { OciErrorInfo info = error.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } 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(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } connected = true; }
public bool BeginSession (OciCredentialType credentialType, OciSessionMode mode, OciErrorHandle error) { errorHandle = error; int status; if (credentialType == OciCredentialType.RDBMS) { if (!SetCredentialAttributes (errorHandle)) return false; } status = OciCalls.OCISessionBegin (Service, errorHandle, Handle, credentialType, mode); if (status != 0) return false; begun = true; return true; }
public void SetAttributeString (string attribute, OciAttributeType attrType, OciErrorHandle errorHandle) { int status = 0; status = OciCalls.OCIAttrSetString (Handle, HandleType, attribute, (uint) attribute.Length, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } }
public void EndSession (OciErrorHandle error) { if (!begun) return; OciCalls.OCISessionEnd (Service, error, this, 0); begun = false; }
public void CreateConnection (OracleConnectionInfo conInfo) { environment = new OciEnvironmentHandle (OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback); if (environment.Handle == IntPtr.Zero) throw new OracleException (0, "Could not allocate the Oracle environment."); service = (OciServiceHandle) environment.Allocate (OciHandleType.Service); if (service == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } error = (OciErrorHandle) environment.Allocate (OciHandleType.Error); if (error == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } service.ErrorHandle = error; server = (OciServerHandle) environment.Allocate (OciHandleType.Server); if (server == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } session = (OciSessionHandle) environment.Allocate (OciHandleType.Session); if (session == null) { OciErrorInfo info = environment.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } session.Username = conInfo.Username; session.Password = conInfo.Password; session.Service = service; if (!server.Attach (conInfo.Database, ErrorHandle)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (!service.SetServer (server)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } #if ORACLE_DATA_ACCESS if (conInfo.SetNewPassword == true) { // open with new password if (!service.SetSession (session)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (!service.ChangePassword (conInfo.NewPassword, error)) { OciErrorInfo info = error.HandleError (); Disconnect (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } conInfo.Password = conInfo.NewPassword; conInfo.SetNewPassword = false; conInfo.NewPassword = string.Empty; } else { #endif // open normally 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 (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } #if ORACLE_DATA_ACCESS } #endif connected = true; }
public void Disconnect() { if (session != null) { session.EndSession (error); session.Dispose (); session = null; } if (server != null) { server.Detach (error); server.Dispose (); server = null; } if (error != null) { error.Dispose (); error = null; } if (service != null) { service.Dispose (); service = null; } if (environment != null) { environment.Dispose (); environment = null; } }
internal bool GetAttributeBool(OciAttributeType attrType, OciErrorHandle errorHandle) { return(GetAttributeInt32(attrType, errorHandle) != 0); }
public bool GetAttributeBool (OciAttributeType attrType, OciErrorHandle errorHandle) { return (GetAttributeInt32 (attrType, errorHandle) != 0); }
public IntPtr GetAttributeIntPtr (OciAttributeType attrType, OciErrorHandle errorHandle) { int status = 0; IntPtr output = IntPtr.Zero; status = OciCalls.OCIAttrGetIntPtr (Handle, HandleType, out output, IntPtr.Zero, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } return output; }
public string GetAttributeString (OciAttributeType attrType, OciErrorHandle errorHandle) { string output = String.Empty; IntPtr outputPtr = IntPtr.Zero; int outSize; int status = 0; status = OciCalls.OCIAttrGet (Handle, HandleType, out outputPtr, out outSize, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } if (outputPtr != IntPtr.Zero && outSize > 0) { object str = Marshal.PtrToStringAnsi (outputPtr, outSize); if (str != null) output = String.Copy ((string) str); } return output; }
public void CreateConnection(OracleConnectionInfo conInfo) { environment = new OciEnvironmentHandle(OciEnvironmentMode.Threaded | OciEnvironmentMode.NoUserCallback); if (environment.Handle == IntPtr.Zero) { throw new OracleException(0, "Could not allocate the Oracle environment."); } service = (OciServiceHandle)environment.Allocate(OciHandleType.Service); if (service == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } error = (OciErrorHandle)environment.Allocate(OciHandleType.Error); if (error == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } service.ErrorHandle = error; server = (OciServerHandle)environment.Allocate(OciHandleType.Server); if (server == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } session = (OciSessionHandle)environment.Allocate(OciHandleType.Session); if (session == null) { OciErrorInfo info = environment.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } session.Username = conInfo.Username; session.Password = conInfo.Password; session.Service = service; if (!server.Attach(conInfo.Database, ErrorHandle)) { OciErrorInfo info = error.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (!service.SetServer(server)) { OciErrorInfo info = error.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } #if ORACLE_DATA_ACCESS if (conInfo.SetNewPassword == true) { // open with new password if (!service.SetSession(session)) { OciErrorInfo info = error.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } if (!service.ChangePassword(conInfo.NewPassword, error)) { OciErrorInfo info = error.HandleError(); Disconnect(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } conInfo.Password = conInfo.NewPassword; conInfo.SetNewPassword = false; conInfo.NewPassword = string.Empty; } else { #endif // open normally 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(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } #if ORACLE_DATA_ACCESS } #endif connected = true; }
internal int GetAttributeInt32 (OciAttributeType attrType, OciErrorHandle errorHandle) { int status = 0; int output; status = OciCalls.OCIAttrGetInt32 (Handle, HandleType, out output, IntPtr.Zero, attrType, errorHandle); if (status != 0) { OciErrorInfo info = OciErrorHandle.HandleError (errorHandle, status); throw new OracleException (info.ErrorCode, info.ErrorMessage); } return output; }
internal void SetAttributeString(string attribute, OciAttributeType attrType, OciErrorHandle errorHandle) { int status = 0; status = OciCalls.OCIAttrSetString(Handle, HandleType, attribute, (uint)attribute.Length, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError(); throw new OracleException(info.ErrorCode, info.ErrorMessage); } }
internal object GetValue(IFormatProvider formatProvider, OracleConnection conn) { object tmp; byte [] buffer = null; switch (DataType) { case OciDataType.VarChar2: case OciDataType.String: case OciDataType.VarChar: case OciDataType.Char: case OciDataType.CharZ: case OciDataType.OciString: case OciDataType.RowIdDescriptor: buffer = new byte [Size]; Marshal.Copy(Value, buffer, 0, Size); // Get length of returned string int rsize = 0; //IntPtr env = Parent.Parent; // Parent is statement, grandparent is environment IntPtr env = conn.Environment; int status = OciCalls.OCICharSetToUnicode(env, null, buffer, out rsize); OciErrorHandle.ThrowExceptionIfError(ErrorHandle, status); // Get string StringBuilder ret = new StringBuilder(rsize); status = OciCalls.OCICharSetToUnicode(env, ret, buffer, out rsize); OciErrorHandle.ThrowExceptionIfError(ErrorHandle, status); return(ret.ToString(0, rsize)); case OciDataType.LongVarChar: case OciDataType.Long: buffer = new byte [LongVarCharMaxValue]; Marshal.Copy(Value, buffer, 0, buffer.Length); int longSize = 0; if (BitConverter.IsLittleEndian) { longSize = BitConverter.ToInt32(new byte[] { buffer[0], buffer[1], buffer[2], buffer[3] }, 0); } else { longSize = BitConverter.ToInt32(new byte[] { buffer[3], buffer[2], buffer[1], buffer[0] }, 0); } ASCIIEncoding encoding = new ASCIIEncoding(); string e = encoding.GetString(buffer, 4, longSize); return(e); case OciDataType.Integer: case OciDataType.Number: case OciDataType.Float: case OciDataType.VarNum: case OciDataType.UnsignedInt: tmp = Marshal.PtrToStringAnsi(Value, Size); if (tmp != null) { return(Decimal.Parse(String.Copy((string)tmp), formatProvider)); } break; case OciDataType.TimeStamp: return(dateTimeDesc.GetDateTime(conn.Environment, dateTimeDesc.ErrorHandle)); case OciDataType.Date: return(UnpackDate()); case OciDataType.Raw: case OciDataType.VarRaw: byte [] raw_buffer = new byte [Size]; Marshal.Copy(Value, raw_buffer, 0, Size); return(raw_buffer); case OciDataType.LongRaw: case OciDataType.LongVarRaw: buffer = new byte [LongVarRawMaxValue]; Marshal.Copy(Value, buffer, 0, buffer.Length); int longrawSize = 0; if (BitConverter.IsLittleEndian) { longrawSize = BitConverter.ToInt32(new byte[] { buffer[0], buffer[1], buffer[2], buffer[3] }, 0); } else { longrawSize = BitConverter.ToInt32(new byte[] { buffer[3], buffer[2], buffer[1], buffer[0] }, 0); } byte[] longraw_buffer = new byte [longrawSize]; Array.ConstrainedCopy(buffer, 4, longraw_buffer, 0, longrawSize); return(longraw_buffer); case OciDataType.Blob: case OciDataType.Clob: return(GetOracleLob()); case OciDataType.IntervalDayToSecond: return(new OracleTimeSpan(intervalDesc.GetDayToSecond(conn.Environment, intervalDesc.ErrorHandle))); case OciDataType.IntervalYearToMonth: return(new OracleMonthSpan(intervalDesc.GetYearToMonth(conn.Environment, intervalDesc.ErrorHandle))); default: throw new Exception("OciDataType not implemented: " + DataType.ToString()); } return(DBNull.Value); }
internal sbyte GetAttributeSByte (OciAttributeType attrType, OciErrorHandle errorHandle) { int status = 0; sbyte output; status = OciCalls.OCIAttrGetSByte (Handle, HandleType, out output, IntPtr.Zero, attrType, errorHandle); if (status != 0) { OciErrorInfo info = errorHandle.HandleError (); throw new OracleException (info.ErrorCode, info.ErrorMessage); } return output; }