/// <devdoc> /// Look into configuration and get the information how the command wrapper should be updated if calling a package on this /// connection. /// </devdoc> private void PreparePackageSchema(ODP10CommandWrapper commandWrapper) { const string allPrefix = "*"; string packageName = String.Empty; string prefix = String.Empty; string commandText = commandWrapper.Command.CommandText; if (CommandType.StoredProcedure == commandWrapper.Command.CommandType) { OracleConnectionStringData oraConnectionString = this.DatabaseProviderData.ConnectionStringData as OracleConnectionStringData; if (oraConnectionString != null) { foreach (OraclePackageData oraPackage in oraConnectionString.OraclePackages) { if ((oraPackage.Prefix == allPrefix) || (commandText.StartsWith(prefix))) { //use the package name for the matching prefix packageName = oraPackage.Name; break; } } } if (0 != packageName.Length) { commandWrapper.Command.CommandText = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", packageName, commandText); } } }
/// <summary> /// <para>Create an <see cref="ODP10CommandWrapper"/> for a SQL query.</para> /// </summary> /// <param name="query"><para>The text of the query.</para></param> /// <returns><para>The <see cref="ODP10CommandWrapper"/> for the SQL query.</para></returns> /// <exception cref="ArgumentNullException"> /// <para><paramref name="query"/> can not be <see langword="null"/> (Nothing in Visual Basic).</para> /// </exception> /// <exception cref="ArgumentException"> /// <para><paramref name="query"/> hast not been initialized.</para> /// </exception> public override DBCommandWrapper GetSqlStringCommandWrapper(string query) { ArgumentValidation.CheckForNullReference(query, "query"); ArgumentValidation.CheckForEmptyString(query, "query"); ODP10CommandWrapper wrapper = new ODP10CommandWrapper(query, CommandType.Text, ParameterToken); return(wrapper); }
/// <summary> /// <para>Create an <see cref="ODP10CommandWrapper"/> for a stored procedure.</para> /// </summary> /// <param name="storedProcedureName"><para>The name of the stored procedure.</para></param> /// <returns><para>The <see cref="ODP10CommandWrapper"/> for the stored procedure.</para></returns> /// <exception cref="ArgumentNullException"> /// <para><paramref name="storedProcedureName"/> can not be <see langword="null"/> (Nothing in Visual Basic).</para> /// </exception> /// <exception cref="ArgumentException"> /// <para><paramref name="storedProcedureName"/> hast not been initialized.</para> /// </exception> public override DBCommandWrapper GetStoredProcCommandWrapper(string storedProcedureName) { ArgumentValidation.CheckForNullReference(storedProcedureName, "storedProcedureName"); ArgumentValidation.CheckForEmptyString(storedProcedureName, "storedProcedureName"); ODP10CommandWrapper wrapper = new ODP10CommandWrapper(storedProcedureName, CommandType.StoredProcedure, ParameterToken); PreparePackageSchema(wrapper); return(wrapper); }
/// <devdoc> /// This is a private method that will build the Oracle package name if your stored procedure /// has proper prefix and postfix. /// This functionality is include for /// the portability of the architecture between SQL and Oracle datbase. /// This method will also add the reference cursor to the command writer if not added already. This /// is required for Oracle .NET managed data provider. /// </devdoc> private static void PrepareCWRefCursor(DBCommandWrapper commandWrapper) { ArgumentValidation.CheckForNullReference(commandWrapper, "commandWrapper"); ODP10CommandWrapper oracleCommandWrapper = (ODP10CommandWrapper)commandWrapper; if (!(oracleCommandWrapper.ParameterDiscoveryRequired)) { if (CommandType.StoredProcedure == commandWrapper.Command.CommandType) { // Check for ref. cursor in the command writer, if it does not exist, add a know reference cursor out // of "cur_OUT" if (!oracleCommandWrapper.IsRefCursorAdded) { oracleCommandWrapper.AddParameter(RefCursorName, OracleDbType.RefCursor, 0, ParameterDirection.Output, true, 0, 0, String.Empty, DataRowVersion.Default, Convert.DBNull); } } } }