Exemplo n.º 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);
        }
Exemplo n.º 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);
    }
Exemplo n.º 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);
        }
Exemplo n.º 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"));
        }
Exemplo n.º 5
0
        public void CanDetermineHasNoReturn()
        {
            string query = @"{ call myFunction(:name) }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.HasReturn, Is.False);
        }
Exemplo n.º 6
0
        public void CanFindCallableFunctionNameWithoutParameters()
        {
            string query = @"{ call myFunction }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.FunctionName, Is.EqualTo("myFunction"));
        }
Exemplo n.º 7
0
        public void CanDetermineIsNotCallable()
        {
            string query = @"SELECT id FROM mytable";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.IsCallable, Is.False);
        }
Exemplo n.º 8
0
        public void CanDetermineIsCallable()
        {
            string query = @"{ call myFunction(:name) }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.IsCallable, Is.True);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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.");
		}
Exemplo n.º 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);
        }
Exemplo n.º 12
0
 		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);
 		}
Exemplo n.º 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++;
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 15
0
 private bool DetermineIfSqlStringHasReturnParameter(SqlString text)
 {
     CallableParser.Detail callableDetail = CallableParser.Parse(text.ToString());
     return(callableDetail.IsCallable && callableDetail.HasReturn);
 }