Пример #1
0
        protected override void OnBeforePrepare(DbCommand command)
        {
            base.OnBeforePrepare(command);

            // need to explicitly turn on named parameter binding
            // http://tgaw.wordpress.com/2006/03/03/ora-01722-with-odp-and-command-parameters/
            _commandBindByNameSetter(command, true);

            var detail = CallableParser.Parse(command.CommandText);

            if (!detail.IsCallable)
            {
                return;
            }
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = detail.FunctionName;
            _commandBindByNameSetter(command, false);

            var outCursor = command.CreateParameter();

            _parameterOracleDbTypeSetter(outCursor, _oracleDbTypeRefCursor);

            outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;

            command.Parameters.Insert(0, outCursor);
        }
Пример #2
0
    protected override void OnBeforePrepare(IDbCommand command)
    {
        base.OnBeforePrepare(command);

        ((OracleCommand)command).BindByName = true;

        IDbProfiler profiler = MiniProfiler.Current;

        if (profiler != null)
        {
            profiler.ExecuteStart((DbCommand)command, ExecuteType.None);
        }

        var detail = CallableParser.Parse(command.CommandText);

        if (!detail.IsCallable)
        {
            return;
        }

        command.CommandType = CommandType.StoredProcedure;
        command.CommandText = detail.FunctionName;

        var outCursor = command.CreateParameter();

        this.oracleDbType.SetValue(outCursor, this.oracleDbTypeRefCursor, null);

        outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;

        command.Parameters.Insert(0, outCursor);
    }
Пример #3
0
        protected override void OnBeforePrepare(IDbCommand command)
        {
            var oracleCommand = (OracleCommand)command;

            base.OnBeforePrepare(oracleCommand);

            // need to explicitly turn on named parameter binding
            // http://tgaw.wordpress.com/2006/03/03/ora-01722-with-odp-and-command-parameters/
            oracleCommand.BindByName = true;

            var detail = CallableParser.Parse(oracleCommand.CommandText);

            if (!detail.IsCallable)
            {
                return;
            }

            oracleCommand.CommandType = CommandType.StoredProcedure;
            oracleCommand.CommandText = detail.FunctionName;
            oracleCommand.BindByName  = false;

            var cursor = oracleCommand.CreateParameter();

            cursor.OracleDbType = OracleDbType.RefCursor;
            cursor.Direction    = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;
            oracleCommand.Parameters.Insert(0, cursor);
        }
Пример #4
0
        public void CanFindCallablePackageFunctionName()
        {
            string query = @"{ call myPackage.No2_Function(:name) }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.FunctionName, Is.EqualTo("myPackage.No2_Function"));
        }
Пример #5
0
        public void CanDetermineHasNoReturn()
        {
            string query = @"{ call myFunction(:name) }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.HasReturn, Is.False);
        }
Пример #6
0
        public void CanFindCallableFunctionNameWithoutParameters()
        {
            string query = @"{ call myFunction }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.FunctionName, Is.EqualTo("myFunction"));
        }
Пример #7
0
        public void CanDetermineIsNotCallable()
        {
            string query = @"SELECT id FROM mytable";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.IsCallable, Is.False);
        }
Пример #8
0
        public void CanDetermineIsCallable()
        {
            string query = @"{ call myFunction(:name) }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.IsCallable, Is.True);
        }
Пример #9
0
        protected override void OnBeforePrepare(IDbCommand command)
        {
            base.OnBeforePrepare(command);

            // need to explicitly turn on named parameter binding
            // http://tgaw.wordpress.com/2006/03/03/ora-01722-with-odp-and-command-parameters/
            oracleCommandBindByName.SetValue(command, true, null);

            CallableParser.Detail detail = CallableParser.Parse(command.CommandText);

            if (!detail.IsCallable)
            {
                return;
            }

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = detail.FunctionName;
            oracleCommandBindByName.SetValue(command, false, null);

            IDbDataParameter outCursor = command.CreateParameter();

            oracleDbType.SetValue(outCursor, oracleDbTypeRefCursor, null);

            //outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;
            outCursor.Direction     = ParameterDirection.Output;
            outCursor.ParameterName = RefCursorName;
            //command.Parameters.Insert(0, outCursor);
            command.Parameters.Add(outCursor);
        }
Пример #10
0
		protected override void OnBeforePrepare(DbCommand command)
		{
			base.OnBeforePrepare(command);

			CallableParser.Detail detail = CallableParser.Parse(command.CommandText);

			if (!detail.IsCallable)
				return;

			throw new System.NotImplementedException(GetType().Name +
				" does not support CallableStatement syntax (stored procedures)." +
				" Consider using OracleDataClientDriver instead.");
		}
Пример #11
0
        protected override void OnBeforePrepare(IDbCommand command)
        {
            base.OnBeforePrepare(command);
            this.oracleCommandBindByName.SetValue(command, true, null);
            CallableParser.Detail detail = CallableParser.Parse(command.CommandText);
            if (!detail.IsCallable)
            {
                return;
            }
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = detail.FunctionName;
            this.oracleCommandBindByName.SetValue(command, false, null);
            IDbDataParameter dbDataParameter = command.CreateParameter();

            this.oracleDbType.SetValue(dbDataParameter, this.oracleDbTypeRefCursor, null);
            dbDataParameter.Direction = (detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output);
            command.Parameters.Insert(0, dbDataParameter);
        }
 		protected override void OnBeforePrepare(IDbCommand command)
 		{
 			base.OnBeforePrepare(command);
 
 			CallableParser.Detail detail = CallableParser.Parse(command.CommandText);
 
 			if (!detail.IsCallable)
 				return;
 
 			command.CommandType = CommandType.StoredProcedure;
 			command.CommandText = detail.FunctionName;
 
 			IDbDataParameter outCursor = command.CreateParameter();
 			oracleDbType.SetValue(outCursor, oracleDbTypeRefCursor, null);
 
 			outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;
 
 			command.Parameters.Insert(0, outCursor);
 		}
Пример #13
0
        private void DetermineNumberOfPreceedingParametersForEachQuery(SqlString text)
        {
            int currentParameterIndex      = 0;
            int currentQueryParameterCount = 0;
            int currentQueryIndex          = 0;

            hasReturnParameter   = false;
            foundReturnParameter = false;

            CallableParser.Detail callableDetail = CallableParser.Parse(text.ToString());

            if (callableDetail.IsCallable && callableDetail.HasReturn)
            {
                hasReturnParameter = true;
            }

            foreach (object part in text.Parts)
            {
                if (part.ToString().Equals(multipleQueriesSeparator))
                {
                    queryIndexToNumberOfPreceedingParameters[currentQueryIndex] = currentParameterIndex - currentQueryParameterCount;
                    currentQueryParameterCount = 0;
                    currentQueryIndex++;
                    continue;
                }

                Parameter parameter = part as Parameter;

                if (parameter != null)
                {
                    if (hasReturnParameter && !foundReturnParameter)
                    {
                        foundReturnParameter = true;
                    }
                    else
                    {
                        parameterIndexToQueryIndex[currentParameterIndex] = currentQueryIndex;
                    }
                    currentQueryParameterCount++;
                    currentParameterIndex++;
                }
            }
        }
Пример #14
0
        protected override void OnBeforePrepare(IDbCommand command)
        {
            base.OnBeforePrepare(command);

            //// http://tgaw.wordpress.com/2006/03/03/ora-01722-with-odp-and-command-parameters/
            this.SetCommandPropertyValue(this.oracleCommandBindByName, command, true);

            var detail = CallableParser.Parse(command.CommandText);

            if (!detail.IsCallable)
            {
                return;
            }

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = detail.FunctionName;
            this.SetCommandPropertyValue(this.oracleCommandBindByName, command, false);

            var outCursor = command.CreateParameter();

            this.oracleDbType.SetValue(outCursor, this.oracleDbTypeRefCursor, null);
            outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;
            command.Parameters.Insert(0, outCursor);
        }
Пример #15
0
 private bool DetermineIfSqlStringHasReturnParameter(SqlString text)
 {
     CallableParser.Detail callableDetail = CallableParser.Parse(text.ToString());
     return(callableDetail.IsCallable && callableDetail.HasReturn);
 }