Esempio n. 1
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                OracleLob lob = _lob;

                if (null != lob)
                {
                    lob.Dispose();
                }
            }

            _lob            = null;
            _fileName       = null;
            _directoryAlias = null;
        }
        object GetValue(int i)
        {
            OciDefineHandle defineHandle = (OciDefineHandle)statement.Values [i];

            if (defineHandle.IsNull)
            {
                return(DBNull.Value);
            }

            switch (defineHandle.DataType)
            {
            case OciDataType.Blob:
            case OciDataType.Clob:
                OracleLob lob   = GetOracleLob(i);
                object    value = lob.Value;
                lob.Dispose();
                return(value);

            default:
                return(defineHandle.GetValue(command.Connection.SessionFormatProvider, command.Connection));
            }
        }
        object ExecuteScalar()
        {
            moreResults = -1;
            object output = null;            //if we find nothing we return this

            AssertConnectionIsOpen();
            AssertTransactionMatch();
            AssertCommandTextIsSet();

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

            OciStatementHandle statement = GetStatementHandle();

            try {
                if (preparedStatement == null)
                {
                    PrepareStatement(statement);
                }

                bool isNonQuery = IsNonQuery(statement);

                BindParameters(statement);

                if (isNonQuery == true)
                {
                    ExecuteNonQueryInternal(statement, false);
                }
                else
                {
                    statement.ExecuteQuery(false);

                    if (statement.Fetch())
                    {
                        OciDefineHandle defineHandle = (OciDefineHandle)statement.Values [0];
                        if (!defineHandle.IsNull)
                        {
                            switch (defineHandle.DataType)
                            {
                            case OciDataType.Blob:
                            case OciDataType.Clob:
                                OracleLob lob = (OracleLob)defineHandle.GetValue(
                                    Connection.SessionFormatProvider, Connection);
                                lob.connection = Connection;
                                output         = lob.Value;
                                lob.Dispose();
                                break;

                            default:
                                output = defineHandle.GetValue(
                                    Connection.SessionFormatProvider, Connection);
                                break;
                            }
                        }
                    }
                    UpdateParameterValues();
                }
            } finally {
                SafeDisposeHandle(statement);
            }

            return(output);
        }