Example #1
0
 internal string GetString(NativeBuffer_RowBuffer buffer)
 {
     if (this.IsLob)
     {
         System.Data.OracleClient.OracleType oracleType = this._metaType.OracleType;
         if (((System.Data.OracleClient.OracleType.Clob != oracleType) && (System.Data.OracleClient.OracleType.NClob != oracleType)) && (System.Data.OracleClient.OracleType.BFile != oracleType))
         {
             throw System.Data.Common.ADP.InvalidCast();
         }
         if (this.IsDBNull(buffer))
         {
             throw System.Data.Common.ADP.DataReaderNoData();
         }
         using (OracleLob lob = new OracleLob(this._lobLocator))
         {
             return((string)lob.Value);
         }
     }
     if (typeof(string) != this._metaType.BaseType)
     {
         throw System.Data.Common.ADP.InvalidCast();
     }
     if (this.IsDBNull(buffer))
     {
         throw System.Data.Common.ADP.DataReaderNoData();
     }
     this.FixupLongValueLength(buffer);
     return(OracleString.MarshalToString(buffer, this._valueOffset, this._lengthOffset, this._metaType, this._connection, this._bindAsUTF16, false));
 }
        private bool IsEmpty(object value)
        {
            bool flag = false;

            if (value is string)
            {
                flag = 0 == ((string)value).Length;
            }
            if (value is OracleString)
            {
                OracleString str = (OracleString)value;
                flag = 0 == str.Length;
            }
            if (value is char[])
            {
                flag = 0 == ((char[])value).Length;
            }
            if (value is byte[])
            {
                flag = 0 == ((byte[])value).Length;
            }
            if (value is OracleBinary)
            {
                OracleBinary binary = (OracleBinary)value;
                flag = 0 == binary.Length;
            }
            return(flag);
        }
Example #3
0
        public int ExecuteOracleNonQuery(out OracleString rowid)
        {
            moreResults = -1;

            AssertConnectionIsOpen();
            AssertTransactionMatch();
            AssertCommandTextIsSet();
            bool useAutoCommit = false;

            if (Transaction != null)
            {
                Transaction.AttachToServiceContext();
            }
            else
            {
                useAutoCommit = true;
            }

            OciStatementHandle statement = GetStatementHandle();

            try
            {
                int retval = ExecuteNonQueryInternal(statement, useAutoCommit);
                OciRowIdDescriptor rowIdDescriptor = statement.GetAttributeRowIdDescriptor(ErrorHandle, Environment);
                string             srowid          = rowIdDescriptor.GetRowIdToString(ErrorHandle);
                rowid           = new OracleString(srowid);
                rowIdDescriptor = null;
                return(retval);
            }
            finally
            {
                SafeDisposeHandle(statement);
            }
        }
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        //
        // Methods
        //
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////

        /// <include file='doc\OracleString.uex' path='docs/doc[@for="OracleString.CompareTo"]/*' />
        public int CompareTo(
            object obj
            )
        {
            if (obj.GetType() == typeof(OracleString))
            {
                OracleString s = (OracleString)obj;

                // If both values are Null, consider them equal.
                // Otherwise, Null is less than anything.
                if (IsNull)
                {
                    return(s.IsNull ? 0  : -1);
                }

                if (s.IsNull)
                {
                    return(1);
                }

                // Neither value is null, do the comparison.
                return(CultureInfo.CurrentCulture.CompareInfo.Compare(_value, s._value));
            }

            // Wrong type!
            throw ADP.Argument();
        }
 public static OracleBoolean GreaterThanOrEqual(OracleString x, OracleString y)
 {
     if (x.IsNull || y.IsNull)
     {
         return(OracleBoolean.Null);
     }
     return(x >= y);
 }
        /// <include file='doc\OracleString.uex' path='docs/doc[@for="OracleString.operator+"]/*' />
        public static OracleString operator+(OracleString x, OracleString y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(Null);
            }

            OracleString result = new OracleString(x._value + y._value);

            return(result);
        }
 public override bool Equals(object value)
 {
     if (value is OracleString)
     {
         OracleString s = (OracleString)value;
         if (notNull && s.notNull)
         {
             return(this.value == s.value);
         }
         else
         {
             throw new InvalidOperationException("the value is Null.");
         }
     }
     return(false);
 }
 public int ExecuteOracleNonQuery(OracleCommand command, out OracleString rowid)
 {
     PrepareCommand(command);
     try
     {
         int result = command.ExecuteOracleNonQuery(out rowid);
     #if DEBUG
         DatabaseLog.WriteInfo(command);
     #endif
         return result;
     }
     catch (Exception e)
     {
         DatabaseLog.WriteError(e.Message, command);
         throw;
     }
 }
        public int ExecuteOracleNonQuery(out OracleString rowid)
        {
            int    num;
            IntPtr ptr;

            OracleConnection.ExecutePermission.Demand();
            Bid.ScopeEnter(out ptr, "<ora.OracleCommand.ExecuteOracleNonQuery|API> %d#\n", this.ObjectID);
            try
            {
                OciRowidDescriptor rowidDescriptor = null;
                int num2 = this.ExecuteNonQueryInternal(true, out rowidDescriptor);
                rowid = GetPersistedRowid(this.Connection, rowidDescriptor);
                OciHandle.SafeDispose(ref rowidDescriptor);
                num = num2;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(num);
        }
 private int ValueSize(object value)
 {
     if (value is OracleString)
     {
         OracleString str = (OracleString)value;
         return(str.Length);
     }
     if (value is string)
     {
         return(((string)value).Length);
     }
     if (value is char[])
     {
         return(((char[])value).Length);
     }
     if (value is OracleBinary)
     {
         OracleBinary binary = (OracleBinary)value;
         return(binary.Length);
     }
     return(this.ValueSizeCore(value));
 }
        public int CompareTo(object obj)
        {
            if (!(obj.GetType() == typeof(OracleString)))
            {
                throw System.Data.Common.ADP.WrongType(obj.GetType(), typeof(OracleString));
            }
            OracleString str = (OracleString)obj;

            if (this.IsNull)
            {
                if (!str.IsNull)
                {
                    return(-1);
                }
                return(0);
            }
            if (str.IsNull)
            {
                return(1);
            }
            return(CultureInfo.CurrentCulture.CompareInfo.Compare(this._value, str._value));
        }
Example #12
0
 public static OracleBoolean NotEquals(OracleString x, OracleString y)
 {
     return(x != y);
 }
Example #13
0
        internal long GetChars(NativeBuffer_RowBuffer buffer, long fieldOffset, char[] destinationBuffer, int destinationOffset, int length)
        {
            int num;

            if (length < 0)
            {
                throw System.Data.Common.ADP.InvalidDataLength((long)length);
            }
            if ((destinationOffset < 0) || ((destinationBuffer != null) && (destinationOffset >= destinationBuffer.Length)))
            {
                throw System.Data.Common.ADP.InvalidDestinationBufferIndex(destinationBuffer.Length, destinationOffset, "bufferoffset");
            }
            if ((0L > fieldOffset) || (0xffffffffL < fieldOffset))
            {
                throw System.Data.Common.ADP.InvalidSourceOffset("fieldOffset", 0L, 0xffffffffL);
            }
            if (this.IsLob)
            {
                System.Data.OracleClient.OracleType oracleType = this._metaType.OracleType;
                if (((System.Data.OracleClient.OracleType.Clob != oracleType) && (System.Data.OracleClient.OracleType.NClob != oracleType)) && (System.Data.OracleClient.OracleType.BFile != oracleType))
                {
                    throw System.Data.Common.ADP.InvalidCast();
                }
                if (this.IsDBNull(buffer))
                {
                    throw System.Data.Common.ADP.DataReaderNoData();
                }
                using (OracleLob lob = new OracleLob(this._lobLocator))
                {
                    string str        = (string)lob.Value;
                    int    maxLen     = str.Length;
                    int    startIndex = (int)fieldOffset;
                    if (startIndex < 0)
                    {
                        throw System.Data.Common.ADP.InvalidSourceBufferIndex(maxLen, (long)startIndex, "fieldOffset");
                    }
                    num = maxLen - startIndex;
                    if (destinationBuffer != null)
                    {
                        num = Math.Min(num, length);
                        if (0 < num)
                        {
                            Buffer.BlockCopy(str.ToCharArray(startIndex, num), 0, destinationBuffer, destinationOffset, num);
                        }
                    }
                    goto Label_0198;
                }
            }
            if ((((System.Data.OracleClient.OracleType.Char != this.OracleType) && (System.Data.OracleClient.OracleType.VarChar != this.OracleType)) && ((System.Data.OracleClient.OracleType.LongVarChar != this.OracleType) && (System.Data.OracleClient.OracleType.NChar != this.OracleType))) && (System.Data.OracleClient.OracleType.NVarChar != this.OracleType))
            {
                throw System.Data.Common.ADP.InvalidCast();
            }
            if (this.IsDBNull(buffer))
            {
                throw System.Data.Common.ADP.DataReaderNoData();
            }
            this.FixupLongValueLength(buffer);
            int num5         = OracleString.GetLength(buffer, this._lengthOffset, this._metaType);
            int sourceOffset = (int)fieldOffset;

            num = num5 - sourceOffset;
            if (destinationBuffer != null)
            {
                num = Math.Min(num, length);
                if (0 < num)
                {
                    OracleString.GetChars(buffer, this._valueOffset, this._lengthOffset, this._metaType, this._connection, this._bindAsUTF16, sourceOffset, destinationBuffer, destinationOffset, num);
                }
            }
Label_0198:
            return((long)Math.Max(0, num));
        }
        internal int PutOracleValue(
            object value,
            HandleRef valueBuffer,
            MetaType metaType,
            OracleConnection connection
            )
        {
            //  writes the managed object into the buffer in the appropriate
            //  native Oracle format.

            OCI.DATATYPE    ociType = metaType.OciType;
            int             dataSize;
            OracleParameter parameter = Parameter;

            switch (ociType)
            {
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.UNSIGNEDINT:
                Marshal.StructureToPtr(value, (IntPtr)valueBuffer, false);
                dataSize = metaType.BindSize;
                break;

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
                dataSize = OracleBinary.MarshalToNative(value, parameter.Offset, parameter.Size, valueBuffer, ociType);
                break;

            case OCI.DATATYPE.DATE:
            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                dataSize = OracleDateTime.MarshalToNative(value, valueBuffer, ociType);
                break;

            case OCI.DATATYPE.BFILE:
                // We cannot construct lobs; if you want to bind a lob, you have to have
                // a lob.
                if (!(value is OracleBFile))
                {
                    throw ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }

                Marshal.WriteIntPtr((IntPtr)valueBuffer, (IntPtr)((OracleBFile)value).Descriptor.Handle);
                dataSize = IntPtr.Size;
                break;

            case OCI.DATATYPE.BLOB:
            case OCI.DATATYPE.CLOB:
                // We cannot construct lobs; if you want to bind a lob, you have to have
                // a lob.
                if (!(value is OracleLob))
                {
                    throw ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }

                // If you don't disable the buffering, you'll cause the PL/SQL code that
                // uses this LOB to have problems doing things like DBMS_LOB.GET_LENGTH()
                ((OracleLob)value).EnsureBuffering(false);

                Marshal.WriteIntPtr((IntPtr)valueBuffer, (IntPtr)((OracleLob)value).Descriptor.Handle);
                dataSize = IntPtr.Size;
                break;

            case OCI.DATATYPE.INT_INTERVAL_YM:
                dataSize = OracleMonthSpan.MarshalToNative(value, valueBuffer);
                break;

            case OCI.DATATYPE.VARNUM:
                dataSize = OracleNumber.MarshalToNative(value, valueBuffer, connection);
                break;

            case OCI.DATATYPE.CHAR:
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
                dataSize = OracleString.MarshalToNative(value, parameter.Offset, parameter.Size, valueBuffer, ociType, _bindAsUCS2);
                break;

            case OCI.DATATYPE.INT_INTERVAL_DS:
                dataSize = OracleTimeSpan.MarshalToNative(value, valueBuffer);
                break;

            default:
                throw ADP.TypeNotSupported(ociType);
            }

            Debug.Assert(dataSize <= _bufferLengthInBytes, String.Format("Internal Error: Exceeded Internal Buffer.  DataSize={0} BufferLength={1}", dataSize, _bufferLengthInBytes));
            return(dataSize);
        }
        internal object GetOutputValue(
            NativeBuffer parameterBuffer,
            OracleConnection connection,                // connection, so we can create LOB values
            bool needCLSType
            )
        {
            object result;

            //  Returns an object that contains the value of the column in the
            //  specified row buffer.  This method returns Oracle-typed objects.

            if (Marshal.ReadInt16((IntPtr)parameterBuffer.Ptr, _indicatorOffset) == (Int16)OCI.INDICATOR.ISNULL)
            {
                return(DBNull.Value);
            }

            switch (_bindingMetaType.OciType)
            {
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.UNSIGNEDINT:
                result = Marshal.PtrToStructure((IntPtr)parameterBuffer.PtrOffset(_valueOffset), _bindingMetaType.BaseType);
                return(result);

            case OCI.DATATYPE.BFILE:
                result = new OracleBFile(_locator);
                return(result);

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
                result = new OracleBinary(parameterBuffer, _valueOffset, _lengthOffset, _bindingMetaType);
                if (needCLSType)
                {
                    object newresult = ((OracleBinary)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.RSET:
                result = new OracleDataReader(connection, _descriptor);
                return(result);

            case OCI.DATATYPE.DATE:
            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                result = new OracleDateTime(parameterBuffer, _valueOffset, _bindingMetaType, connection);
                if (needCLSType)
                {
                    object newresult = ((OracleDateTime)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.BLOB:
            case OCI.DATATYPE.CLOB:
                result = new OracleLob(_locator);
                return(result);

            case OCI.DATATYPE.INT_INTERVAL_YM:
                result = new OracleMonthSpan(parameterBuffer, _valueOffset);
                if (needCLSType)
                {
                    object newresult = ((OracleMonthSpan)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.VARNUM:
                result = new OracleNumber(parameterBuffer, _valueOffset);
                if (needCLSType)
                {
                    object newresult = ((OracleNumber)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.CHAR:
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
                result = new OracleString(parameterBuffer,
                                          _valueOffset,
                                          _lengthOffset,
                                          _bindingMetaType,
                                          connection,
                                          _bindAsUCS2,
                                          true
                                          );
                int size = _parameter.Size;
                if (0 != size && size < ((OracleString)result).Length)
                {
                    string truncatedResult = ((OracleString)result).Value.Substring(0, size);
                    if (needCLSType)
                    {
                        result = truncatedResult;
                    }
                    else
                    {
                        result = new OracleString(truncatedResult);
                    }
                }
                else if (needCLSType)
                {
                    object newresult = ((OracleString)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.INT_INTERVAL_DS:
                result = new OracleTimeSpan(parameterBuffer, _valueOffset);
                if (needCLSType)
                {
                    object newresult = ((OracleTimeSpan)result).Value;
                    result = newresult;
                }
                return(result);
            }
            throw ADP.TypeNotSupported(_bindingMetaType.OciType);
        }
Example #16
0
		public int ExecuteOracleNonQuery (out OracleString rowid)
		{
			moreResults = -1;

			AssertConnectionIsOpen ();
			AssertTransactionMatch ();
			AssertCommandTextIsSet ();
			bool useAutoCommit = false;

			if (Transaction != null)
				Transaction.AttachToServiceContext ();
			else
				useAutoCommit = true;

			OciStatementHandle statement = GetStatementHandle ();

			try {
				int retval = ExecuteNonQueryInternal (statement, useAutoCommit);
				OciRowIdDescriptor rowIdDescriptor = statement.GetAttributeRowIdDescriptor (ErrorHandle, Environment);
				string srowid = rowIdDescriptor.GetRowIdToString (ErrorHandle);
				rowid = new OracleString (srowid);
				rowIdDescriptor = null;
				return retval;
			} finally {
				SafeDisposeHandle (statement);
			}
		}
		public int ExecuteOracleNonQuery (out OracleString rowid)
		{
			AssertConnectionIsOpen ();
			AssertTransactionMatch ();
			AssertCommandTextIsSet ();
			bool useAutoCommit = false; 

			if (Transaction != null)
				Transaction.AttachToServiceContext ();
			else
				useAutoCommit = true;

			OciStatementHandle statement = GetStatementHandle ();

			try {
				int retval = ExecuteNonQueryInternal (statement, useAutoCommit);

				OciRowIdDescriptor descriptor = (OciRowIdDescriptor) Environment.Allocate (OciHandleType.RowId);
				descriptor.SetHandle (statement.GetAttributeIntPtr (OciAttributeType.RowId, ErrorHandle));

				rowid = new OracleString (descriptor.GetRowId (ErrorHandle));

				return retval;
			}
			finally	{
				SafeDisposeHandle (statement);
			}
		}
        internal static OracleString GetPersistedRowid(OracleConnection connection, OciRowidDescriptor rowidHandle)
        {
            OracleString @null = OracleString.Null;

            if (rowidHandle != null)
            {
                OciErrorHandle errorHandle   = connection.ErrorHandle;
                NativeBuffer   scratchBuffer = connection.GetScratchBuffer(0xf82);
                bool           success       = false;
                bool           flag          = false;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    int num;
                    scratchBuffer.DangerousAddRef(ref success);
                    if (OCI.ClientVersionAtLeastOracle9i)
                    {
                        int length = scratchBuffer.Length;
                        num = TracedNativeMethods.OCIRowidToChar(rowidHandle, scratchBuffer, ref length, errorHandle);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        return(new OracleString(scratchBuffer.PtrToStringAnsi(0, length)));
                    }
                    rowidHandle.DangerousAddRef(ref flag);
                    OciServiceContextHandle serviceContextHandle = connection.ServiceContextHandle;
                    OciStatementHandle      stmtp = new OciStatementHandle(serviceContextHandle);
                    string stmt   = "begin :rowid := :rdesc; end;";
                    int    offset = 0;
                    int    num6   = 4;
                    int    num5   = 8;
                    int    num3   = 12;
                    int    num2   = 0x10;
                    int    num4   = 20;
                    try
                    {
                        IntPtr ptr;
                        IntPtr ptr2;
                        num = TracedNativeMethods.OCIStmtPrepare(stmtp, errorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, connection);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        scratchBuffer.WriteIntPtr(num5, rowidHandle.DangerousGetHandle());
                        scratchBuffer.WriteInt32(offset, 0);
                        scratchBuffer.WriteInt32(num6, 4);
                        scratchBuffer.WriteInt32(num3, 0);
                        scratchBuffer.WriteInt32(num2, 0xf6e);
                        num = TracedNativeMethods.OCIBindByName(stmtp, out ptr2, errorHandle, "rowid", 5, scratchBuffer.DangerousGetDataPtr(num4), 0xf6e, OCI.DATATYPE.VARCHAR2, scratchBuffer.DangerousGetDataPtr(num3), scratchBuffer.DangerousGetDataPtr(num2), OCI.MODE.OCI_DEFAULT);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        num = TracedNativeMethods.OCIBindByName(stmtp, out ptr, errorHandle, "rdesc", 5, scratchBuffer.DangerousGetDataPtr(num5), 4, OCI.DATATYPE.ROWID_DESC, scratchBuffer.DangerousGetDataPtr(offset), scratchBuffer.DangerousGetDataPtr(num6), OCI.MODE.OCI_DEFAULT);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        num = TracedNativeMethods.OCIStmtExecute(serviceContextHandle, stmtp, errorHandle, 1, OCI.MODE.OCI_DEFAULT);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        if (scratchBuffer.ReadInt16(num3) == -1)
                        {
                            return(@null);
                        }
                        @null = new OracleString(scratchBuffer, num4, num2, MetaType.GetMetaTypeForType(OracleType.RowId), connection, false, true);
                        GC.KeepAlive(rowidHandle);
                    }
                    finally
                    {
                        OciHandle.SafeDispose(ref stmtp);
                    }
                }
                finally
                {
                    if (flag)
                    {
                        rowidHandle.DangerousRelease();
                    }
                    if (success)
                    {
                        scratchBuffer.DangerousRelease();
                    }
                }
            }
            return(@null);
        }
Example #19
0
 public static OracleString Concat(OracleString x, OracleString y)
 {
     return(x + y);
 }
Example #20
0
 public static OracleBoolean LessThan(OracleString x, OracleString y)
 {
     return(x < y);
 }
 public static OracleString Concat(OracleString x, OracleString y)
 {
     return (x + y);
 }
 internal static OracleString GetPersistedRowid(OracleConnection connection, OciRowidDescriptor rowidHandle)
 {
     OracleString @null = OracleString.Null;
     if (rowidHandle != null)
     {
         OciErrorHandle errorHandle = connection.ErrorHandle;
         NativeBuffer scratchBuffer = connection.GetScratchBuffer(0xf82);
         bool success = false;
         bool flag = false;
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             int num;
             scratchBuffer.DangerousAddRef(ref success);
             if (OCI.ClientVersionAtLeastOracle9i)
             {
                 int length = scratchBuffer.Length;
                 num = TracedNativeMethods.OCIRowidToChar(rowidHandle, scratchBuffer, ref length, errorHandle);
                 if (num != 0)
                 {
                     connection.CheckError(errorHandle, num);
                 }
                 return new OracleString(scratchBuffer.PtrToStringAnsi(0, length));
             }
             rowidHandle.DangerousAddRef(ref flag);
             OciServiceContextHandle serviceContextHandle = connection.ServiceContextHandle;
             OciStatementHandle stmtp = new OciStatementHandle(serviceContextHandle);
             string stmt = "begin :rowid := :rdesc; end;";
             int offset = 0;
             int num6 = 4;
             int num5 = 8;
             int num3 = 12;
             int num2 = 0x10;
             int num4 = 20;
             try
             {
                 IntPtr ptr;
                 IntPtr ptr2;
                 num = TracedNativeMethods.OCIStmtPrepare(stmtp, errorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, connection);
                 if (num != 0)
                 {
                     connection.CheckError(errorHandle, num);
                 }
                 scratchBuffer.WriteIntPtr(num5, rowidHandle.DangerousGetHandle());
                 scratchBuffer.WriteInt32(offset, 0);
                 scratchBuffer.WriteInt32(num6, 4);
                 scratchBuffer.WriteInt32(num3, 0);
                 scratchBuffer.WriteInt32(num2, 0xf6e);
                 num = TracedNativeMethods.OCIBindByName(stmtp, out ptr2, errorHandle, "rowid", 5, scratchBuffer.DangerousGetDataPtr(num4), 0xf6e, OCI.DATATYPE.VARCHAR2, scratchBuffer.DangerousGetDataPtr(num3), scratchBuffer.DangerousGetDataPtr(num2), OCI.MODE.OCI_DEFAULT);
                 if (num != 0)
                 {
                     connection.CheckError(errorHandle, num);
                 }
                 num = TracedNativeMethods.OCIBindByName(stmtp, out ptr, errorHandle, "rdesc", 5, scratchBuffer.DangerousGetDataPtr(num5), 4, OCI.DATATYPE.ROWID_DESC, scratchBuffer.DangerousGetDataPtr(offset), scratchBuffer.DangerousGetDataPtr(num6), OCI.MODE.OCI_DEFAULT);
                 if (num != 0)
                 {
                     connection.CheckError(errorHandle, num);
                 }
                 num = TracedNativeMethods.OCIStmtExecute(serviceContextHandle, stmtp, errorHandle, 1, OCI.MODE.OCI_DEFAULT);
                 if (num != 0)
                 {
                     connection.CheckError(errorHandle, num);
                 }
                 if (scratchBuffer.ReadInt16(num3) == -1)
                 {
                     return @null;
                 }
                 @null = new OracleString(scratchBuffer, num4, num2, MetaType.GetMetaTypeForType(OracleType.RowId), connection, false, true);
                 GC.KeepAlive(rowidHandle);
             }
             finally
             {
                 OciHandle.SafeDispose(ref stmtp);
             }
         }
         finally
         {
             if (flag)
             {
                 rowidHandle.DangerousRelease();
             }
             if (success)
             {
                 scratchBuffer.DangerousRelease();
             }
         }
     }
     return @null;
 }
 public int ExecuteOracleNonQuery(out OracleString rowid)
 {
     int num;
     IntPtr ptr;
     OracleConnection.ExecutePermission.Demand();
     Bid.ScopeEnter(out ptr, "<ora.OracleCommand.ExecuteOracleNonQuery|API> %d#\n", this.ObjectID);
     try
     {
         OciRowidDescriptor rowidDescriptor = null;
         int num2 = this.ExecuteNonQueryInternal(true, out rowidDescriptor);
         rowid = GetPersistedRowid(this.Connection, rowidDescriptor);
         OciHandle.SafeDispose(ref rowidDescriptor);
         num = num2;
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
     return num;
 }
 static OracleString()
 {
     Empty = new OracleString(false);
     Null  = new OracleString(true);
 }
 public static OracleBoolean GreaterThanOrEqual(OracleString x, OracleString y)
 {
     return(x >= y);
 }
 public static OracleBoolean GreaterThan(OracleString x, OracleString y)
 {
     return(x > y);
 }
Example #27
0
 public static OracleBoolean LessThanOrEqual(OracleString x, OracleString y)
 {
     return(x <= y);
 }
        internal int PutOracleValue(object value, NativeBuffer buffer, int bufferOffset, MetaType metaType, OracleConnection connection, ref SafeHandle handleToBind)
        {
            handleToBind = null;
            OCI.DATATYPE    ociType   = metaType.OciType;
            OracleParameter parameter = this.Parameter;

            switch (ociType)
            {
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
            case OCI.DATATYPE.CHAR:
                return(OracleString.MarshalToNative(value, parameter.Offset, parameter.GetActualSize(), buffer, bufferOffset, ociType, this._bindAsUCS2));

            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.UNSIGNEDINT:
                buffer.StructureToPtr(bufferOffset, value);
                return(metaType.BindSize);

            case OCI.DATATYPE.VARNUM:
                return(OracleNumber.MarshalToNative(value, buffer, bufferOffset, connection));

            case OCI.DATATYPE.DATE:
                return(OracleDateTime.MarshalDateToNative(value, buffer, bufferOffset, ociType, connection));

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
            {
                int    num;
                byte[] buffer2;
                if (this._coercedValue is OracleBinary)
                {
                    OracleBinary binary = (OracleBinary)this._coercedValue;
                    buffer2 = binary.Value;
                }
                else
                {
                    buffer2 = (byte[])this._coercedValue;
                }
                int num2       = buffer2.Length - parameter.Offset;
                int actualSize = parameter.GetActualSize();
                if (actualSize != 0)
                {
                    num2 = Math.Min(num2, actualSize);
                }
                if (OCI.DATATYPE.LONGVARRAW == ociType)
                {
                    buffer.WriteInt32(bufferOffset, num2);
                    bufferOffset += 4;
                    num           = num2 + 4;
                }
                else
                {
                    num = num2;
                }
                buffer.WriteBytes(bufferOffset, buffer2, parameter.Offset, num2);
                return(num);
            }

            case OCI.DATATYPE.CLOB:
            case OCI.DATATYPE.BLOB:
                if (!(value is OracleLob))
                {
                    throw System.Data.Common.ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }
                handleToBind = ((OracleLob)value).Descriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.BFILE:
                if (!(value is OracleBFile))
                {
                    throw System.Data.Common.ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }
                handleToBind = ((OracleBFile)value).Descriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                if (value is OracleDateTime)
                {
                    OracleDateTime time = (OracleDateTime)value;
                    if (!time.HasTimeInfo)
                    {
                        throw System.Data.Common.ADP.UnsupportedOracleDateTimeBinding(metaType.OracleType);
                    }
                }
                this._dateTimeDescriptor = OracleDateTime.CreateDescriptor(ociType, connection, value);
                handleToBind             = this._dateTimeDescriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                if (value is OracleDateTime)
                {
                    OracleDateTime time2 = (OracleDateTime)value;
                    if (!time2.HasTimeZoneInfo)
                    {
                        throw System.Data.Common.ADP.UnsupportedOracleDateTimeBinding(OracleType.TimestampWithTZ);
                    }
                }
                this._dateTimeDescriptor = OracleDateTime.CreateDescriptor(ociType, connection, value);
                handleToBind             = this._dateTimeDescriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.INT_INTERVAL_YM:
                return(OracleMonthSpan.MarshalToNative(value, buffer, bufferOffset));

            case OCI.DATATYPE.INT_INTERVAL_DS:
                return(OracleTimeSpan.MarshalToNative(value, buffer, bufferOffset));
            }
            throw System.Data.Common.ADP.TypeNotSupported(ociType);
        }
 public static OracleBoolean GreaterThanOrEqual(OracleString x, OracleString y)
 {
     return (x >= y);
 }
 static OracleString()
 {
     Empty = new OracleString(false);
     Null = new OracleString(true);
 }
 public static OracleBoolean LessThanOrEqual(OracleString x, OracleString y)
 {
     return (x <= y);
 }
        internal object GetOutputValue(NativeBuffer parameterBuffer, OracleConnection connection, bool needCLSType)
        {
            object obj2;

            if (parameterBuffer.ReadInt16(this._indicatorOffset) == -1)
            {
                return(DBNull.Value);
            }
            switch (this._bindingMetaType.OciType)
            {
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
            case OCI.DATATYPE.CHAR:
            {
                obj2 = new OracleString(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection, this._bindAsUCS2, true);
                int size = this._parameter.Size;
                if (size != 0)
                {
                    OracleString str4 = (OracleString)obj2;
                    if (size < str4.Length)
                    {
                        OracleString str3 = (OracleString)obj2;
                        string       s    = str3.Value.Substring(0, size);
                        if (needCLSType)
                        {
                            return(s);
                        }
                        return(new OracleString(s));
                    }
                }
                if (needCLSType)
                {
                    OracleString str2 = (OracleString)obj2;
                    obj2 = str2.Value;
                }
                return(obj2);
            }

            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.UNSIGNEDINT:
                return(parameterBuffer.PtrToStructure(this._valueOffset, this._bindingMetaType.BaseType));

            case OCI.DATATYPE.VARNUM:
                obj2 = new OracleNumber(parameterBuffer, this._valueOffset);
                if (needCLSType)
                {
                    OracleNumber number = (OracleNumber)obj2;
                    obj2 = number.Value;
                }
                return(obj2);

            case OCI.DATATYPE.DATE:
                obj2 = new OracleDateTime(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection);
                if (needCLSType)
                {
                    OracleDateTime time2 = (OracleDateTime)obj2;
                    obj2 = time2.Value;
                }
                return(obj2);

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
                obj2 = new OracleBinary(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType);
                if (needCLSType)
                {
                    OracleBinary binary = (OracleBinary)obj2;
                    obj2 = binary.Value;
                }
                return(obj2);

            case OCI.DATATYPE.CLOB:
            case OCI.DATATYPE.BLOB:
                return(new OracleLob(this._locator));

            case OCI.DATATYPE.BFILE:
                return(new OracleBFile(this._locator));

            case OCI.DATATYPE.RSET:
                return(new OracleDataReader(connection, this._descriptor));

            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                obj2 = new OracleDateTime(this._dateTimeDescriptor, this._bindingMetaType, connection);
                if (needCLSType)
                {
                    OracleDateTime time = (OracleDateTime)obj2;
                    obj2 = time.Value;
                }
                return(obj2);

            case OCI.DATATYPE.INT_INTERVAL_YM:
                obj2 = new OracleMonthSpan(parameterBuffer, this._valueOffset);
                if (needCLSType)
                {
                    OracleMonthSpan span2 = (OracleMonthSpan)obj2;
                    obj2 = span2.Value;
                }
                return(obj2);

            case OCI.DATATYPE.INT_INTERVAL_DS:
                obj2 = new OracleTimeSpan(parameterBuffer, this._valueOffset);
                if (needCLSType)
                {
                    OracleTimeSpan span = (OracleTimeSpan)obj2;
                    obj2 = span.Value;
                }
                return(obj2);
            }
            throw System.Data.Common.ADP.TypeNotSupported(this._bindingMetaType.OciType);
        }
 public static OracleBoolean GreaterThan(OracleString x, OracleString y)
 {
     return (x > y);
 }
Example #34
0
		public static OracleBoolean GreaterThanOrEqual (OracleString x, OracleString y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return (x  >= y);
		}
 public static OracleBoolean LessThan(OracleString x, OracleString y)
 {
     return (x < y);
 }
Example #36
0
        public static void insertTest(string connStr)
        {
            //            string sql = @"
            //
            //select t1_seq.CurrVal FROM DUAL
            //";
            //string sql = @"BEGIN SELECT 12 INTO :1 FROM DUAL; END;";
            string sql = "BEGIN insert INTO t1 (id1) values (t1_seq.NextVal);\n select t1_seq.CurrVal INTO :1 FROM DUAL; END;";
#if ORACLE_PROVIDER
            //Oracle provider - download from http://www.oracle.com/technology/software/tech/windows/odpnet/utilsoft_11gbeta.html
            //Oracle provider (check via TNSPING): "User Id=Scott;Password=tiger;Data Source=orcl9i"
            connStr = "User Id=Northwind;Password=linq2;Data Source=XE";
#else
            //Microsoft provider: System.Data.OracleClient
            //see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1055859&SiteID=1
#endif
            OracleConnection conn = new OracleConnection(connStr);
            conn.Open();

            //OracleCommand cmd = new OracleCommand(sql, conn);
            //cmd.CommandType = System.Data.CommandType.Text;
            OracleCommand cmd = conn.CreateCommand();
            OracleParameter p1 = new OracleParameter("1", OracleType.Number);
            p1.Direction = System.Data.ParameterDirection.Output;
            cmd.Parameters.Add(p1);

            OracleString os = new OracleString();
            try
            {
                //conn.Open();
                try
                {
                    //cmd.CommandText = "begin dbms_output.enable; end;";
                    cmd.CommandText = sql;
                    //cmd.ExecuteOracleNonQuery(out os);
                    object obj1 = cmd.ExecuteScalar();
                    Type tt2 = obj1.GetType();
                }
                catch (OracleException ex)
                {
                    //MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Console.WriteLine("Failed: " + ex);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed: " + ex);
            }
            //int result = cmd.ExecuteNonQuery();
            //object result = cmd.ExecuteOracleScalar();
            object result = cmd.ExecuteScalar();
            Type tt = result.GetType();
            //result++;
        }
 public static OracleBoolean NotEquals(OracleString x, OracleString y)
 {
     return (x != y);
 }
Example #38
0
		public int ExecuteOracleNonQuery(
			out OracleString rowid
			) {
			throw new NotImplementedException();
		}
        internal object GetOutputValue(NativeBuffer parameterBuffer, OracleConnection connection, bool needCLSType)
        {
            object obj2;
            if (parameterBuffer.ReadInt16(this._indicatorOffset) == -1)
            {
                return DBNull.Value;
            }
            switch (this._bindingMetaType.OciType)
            {
                case OCI.DATATYPE.VARCHAR2:
                case OCI.DATATYPE.LONG:
                case OCI.DATATYPE.LONGVARCHAR:
                case OCI.DATATYPE.CHAR:
                {
                    obj2 = new OracleString(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection, this._bindAsUCS2, true);
                    int size = this._parameter.Size;
                    if (size != 0)
                    {
                        OracleString str4 = (OracleString) obj2;
                        if (size < str4.Length)
                        {
                            OracleString str3 = (OracleString) obj2;
                            string s = str3.Value.Substring(0, size);
                            if (needCLSType)
                            {
                                return s;
                            }
                            return new OracleString(s);
                        }
                    }
                    if (needCLSType)
                    {
                        OracleString str2 = (OracleString) obj2;
                        obj2 = str2.Value;
                    }
                    return obj2;
                }
                case OCI.DATATYPE.INTEGER:
                case OCI.DATATYPE.FLOAT:
                case OCI.DATATYPE.UNSIGNEDINT:
                    return parameterBuffer.PtrToStructure(this._valueOffset, this._bindingMetaType.BaseType);

                case OCI.DATATYPE.VARNUM:
                    obj2 = new OracleNumber(parameterBuffer, this._valueOffset);
                    if (needCLSType)
                    {
                        OracleNumber number = (OracleNumber) obj2;
                        obj2 = number.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.DATE:
                    obj2 = new OracleDateTime(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection);
                    if (needCLSType)
                    {
                        OracleDateTime time2 = (OracleDateTime) obj2;
                        obj2 = time2.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.RAW:
                case OCI.DATATYPE.LONGRAW:
                case OCI.DATATYPE.LONGVARRAW:
                    obj2 = new OracleBinary(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType);
                    if (needCLSType)
                    {
                        OracleBinary binary = (OracleBinary) obj2;
                        obj2 = binary.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.CLOB:
                case OCI.DATATYPE.BLOB:
                    return new OracleLob(this._locator);

                case OCI.DATATYPE.BFILE:
                    return new OracleBFile(this._locator);

                case OCI.DATATYPE.RSET:
                    return new OracleDataReader(connection, this._descriptor);

                case OCI.DATATYPE.INT_TIMESTAMP:
                case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                    obj2 = new OracleDateTime(this._dateTimeDescriptor, this._bindingMetaType, connection);
                    if (needCLSType)
                    {
                        OracleDateTime time = (OracleDateTime) obj2;
                        obj2 = time.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.INT_INTERVAL_YM:
                    obj2 = new OracleMonthSpan(parameterBuffer, this._valueOffset);
                    if (needCLSType)
                    {
                        OracleMonthSpan span2 = (OracleMonthSpan) obj2;
                        obj2 = span2.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.INT_INTERVAL_DS:
                    obj2 = new OracleTimeSpan(parameterBuffer, this._valueOffset);
                    if (needCLSType)
                    {
                        OracleTimeSpan span = (OracleTimeSpan) obj2;
                        obj2 = span.Value;
                    }
                    return obj2;
            }
            throw System.Data.Common.ADP.TypeNotSupported(this._bindingMetaType.OciType);
        }
		public static OracleBoolean GreaterThanOrEqual (OracleString x, OracleString y)
		{
			throw new NotImplementedException ();
		}