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); }
public void CanDetermineHasNoReturn() { string query = @"{ call myFunction(:name) }"; CallableParser.Detail detail = CallableParser.Parse(query); Assert.That(detail.HasReturn, Is.False); }
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")); }
public void CanFindCallableFunctionNameWithoutParameters() { string query = @"{ call myFunction }"; CallableParser.Detail detail = CallableParser.Parse(query); Assert.That(detail.FunctionName, Is.EqualTo("myFunction")); }
public void CanDetermineIsNotCallable() { string query = @"SELECT id FROM mytable"; CallableParser.Detail detail = CallableParser.Parse(query); Assert.That(detail.IsCallable, Is.False); }
public void CanDetermineIsCallable() { string query = @"{ call myFunction(:name) }"; CallableParser.Detail detail = CallableParser.Parse(query); Assert.That(detail.IsCallable, Is.True); }
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."); }
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); }
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++; } } }
private bool DetermineIfSqlStringHasReturnParameter(SqlString text) { CallableParser.Detail callableDetail = CallableParser.Parse(text.ToString()); return(callableDetail.IsCallable && callableDetail.HasReturn); }