Exemple #1
0
        public object ExecuteOracleScalar()
        {
            moreResults = -1;

            object output = DBNull.Value;

            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)
                        {
                            output = defineHandle.GetOracleValue(Connection.SessionFormatProvider, Connection);
                        }
                        switch (defineHandle.DataType)
                        {
                        case OciDataType.Blob:
                        case OciDataType.Clob:
                            ((OracleLob)output).connection = Connection;
                            break;
                        }
                    }
                    UpdateParameterValues();
                }

                return(output);
            } finally {
                SafeDisposeHandle(statement);
            }
        }
Exemple #2
0
        public override bool Read()
        {
            ValidateState();

            if (hasRows)
            {
                bool retval = statement.Fetch();
                hasRows = retval;
                return(retval);
            }
            return(false);
        }