Esempio 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/
            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);

            var outCursor = command.CreateParameter();

            oracleDbType.SetValue(outCursor, oracleDbTypeRefCursor, null);

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

            command.Parameters.Insert(0, outCursor);
        }
Esempio n. 2
0
        public void CanDetermineHasNoReturn()
        {
            string query = @"{ call myFunction(:name) }";

            CallableParser.Detail detail = CallableParser.Parse(query);
            Assert.That(detail.HasReturn, Is.False);
        }
Esempio n. 3
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"));
        }
Esempio n. 4
0
        public void CanFindCallableFunctionNameWithoutParameters()
        {
            string query = @"{ call myFunction }";

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

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

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