Index in Query inside Stored procedure

How to put a index on Select query inside a stored procedure.Please help me on below to write a index
Coalesce ((select sum (ICD.mAmount)
from ItemCommonData ICD (Index(PK_ItemCommonData))
Join ItemsInBundle IIBun on
(ICD.iBundleDocId = IIBun.iBundleDocId) and
(ICD.iDocId = IIBun.iDocId)
Join ItemsInBlock IIB (Index(ItemsInBlockbyBlockDoc)) on
(ICD.iDocId = IIB.iDocId)
where (Bundles.iDocId = ICD.iBundleDocId
and IIBun.fDeleted = False
and IIB.iBlockId = iBlockId)),

Are you migrating to Oracle SQL and PL/SQL?
Anyway, you don't define an Index on the fly in Oracle. You create them ahead of time on the table. You can use hints to manipulate the query into using a certain execution path.

Similar Messages

  • Query a stored procedure

    Hi
    I am using oracle 10g R2 and i am wondering if there is any way which i can query a stored procedure.
    lets say have this table
    EMP
    1
    2
    3
    and i want from a stored procedure to return all this values
    like
    select * from stored_proc;
    is this possible in any way?
    thx
    Doron

    the idea behind all this mess is because we have a hierarchic query which gets parameters to query by.
    i thought of creating a view but then i colud not pass the parameters to it.
    if no solution will be found i will have to change the code but we prefer to try and find this kind of solution
    Doron

  • Failed to retrieve all the results. Try running the query or stored procedure again

    I have a Product table in Azure SQL Database. I can't open data in Product table. I got an error message like this.."Failed to retrieve all the results. Try running the query or stored procedure again". In my Database
    all tables showing their data expect Product table. Please let me know why only Product table showing error message. Thanks in Advance.

    Hi,
    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience
    As this requires an expert advice, I suggest you to open a support case and our experts would be able to assist you further.
    http://support2.microsoft.com/common/international.aspx?RDPATH=%2fdefault.aspx%3fid%3dfh%253ben-us%253bofferprophone
    Girish Prajwal

  • Problem in package run inside stored procedure

    i have ssis package to import data from excel to database.
    package is running correctly inside BIDS.
    but when i run package under stored procedure it is giving error :
    Error:   Code: 0xC0014023
       Source: loop sheets in excel
       Description: The GetEnumerator method of the ForEach Enumerator has failed with error 0x80040E21 "(null)". This occurs when the ForEach Enumerator cannot enumerate.

    Hi BI_DEV_19,
    Does the package connects with network resources? If so, try set the job step to run under a proxy account that is created based on a domain account. In BIDS, the package runs under the Windows account that you log onto the operating system.
    The error message “The GetEnumerator method of the ForEach Enumerator has failed with error 0x80040E21” may occur because the ADODB.dll file is corrupted or missing.  You can check whether the ADODB.dll exists in the following folder:
    C:\program files (x86)\Microsoft.NET\Primary Interop Assemblies
    In this situation, you can back up the existing ADODB.dll file, and copy one from another machine to this server.
    Regards,
    Mike Yin
    TechNet Community Support

  • Program does not break at breakpoint inside stored procedure

    I am using VS 2013 and SQL Server 2012 calling a stored procedure from a C# program. I have a breakpoint set inside the stored procedure, however execution does not stop on it. When my program is running, the breakpoint is hollow (not solid red) and the
    tool tip reads "the breakpoint will not currently be hit. No symbols have been loaded for this document".
    I built my app in debug mode and checked "SQL debugging" in the debug tab.
    Any idea as to what would cause my breakpoint to not work?
    Thanks!
    -A

    Hi achalk,
    When debugging SQL Server stored procedure in Visual Studio 2013, please make sure that Application Debugging is selected in "SQL Server Object Explorer", otherwise you will not be able to step into T-SQL.
    There are similar articles for your reference.
    Debug SQL Server 2012 Stored Procedure in Visual Studio 2013, Step by Step
    http://database.ca/blog.aspx?blogid=10
    How to debug SQL Server T-SQL in Visual Studio 2012
    http://stackoverflow.com/questions/12016417/how-to-debug-sql-server-t-sql-in-visual-studio-2012
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.
    Lydia Zhang
    TechNet Community Support

  • Query in Stored Procedure accessing another schema

    Hi - this is going to sound kind of strange and even i can't come up with an explanation. My JDK 1.1.7 applet uses a type 4 JDBC thin driver (i think v 8.04.06) to access an Oracle 7.3.4 database. We also have a link with full grants and synonymns to another Oracle schema in an Oracle 8 database. Has never been a problem - we can access anything we need to through queries or stored procedures from either of these databases.
    So, i have a new stored procedure that needs to be called through JDBC that queries a table in the Oracle 8 database. For some reason, whenever i execute this stored procedure from java it hangs on this query and the instance needs to be restarted. If i execute that same stored procedure from SQL Plus, it runs fine.
    I tried a little test. I put a straight query in my java code that goes directly to that table (no stored procedure involved). It runs great through java!
    is this weird or what? my dbas have checked out all privelages and it seems that i have access to everything i could possibly need.
    If anyone has any suggestions i would love to hear them.
    thanks for your help...
    Lori - [email protected]
    null

    You can only access an object in another user's schema if you either:
    (a) Specify the 'other' schema name explicitly: SCHEMA.OBJECT
    (b) A synonymn has been created to access the object: CREATE SYNONYM OBJECT FOR SCHEMA.OBJECT.
    The user requiring the synonym should create it, or the user owning the object can create a PUBLIC synonym, if they have the authority.
    To check my hypothesis, try typing 'DESCRIBE procedure_name' from SQL*Plus as both users.

  • Query a stored procedure that exec's a dynamic query. Error Linked server indicates object has no columns

    I have a stored procedure that dynamically creates a pivot query.  The procedure works and returns the correct data.  Now I have a requirement to show this data in reporting system that can only pull from a table or view.  Since you can not
    create a dynamic query in a view I tried to do a select from using openquery. 
    Example 'Select * from OpenQuery([MyServername], 'Exec Instance.Schema.StoredProcedure')
    I get the error back "the linked server indicates the object has no columns".  I assume this is because of the first select statement that is stuffing the variable with column names. 
    CODE FROM PROCEDURE
    Alter PROCEDURE [dbo].[Procedure1]
    AS
    BEGIN
    SET NOCOUNT ON
    Declare @cols nvarchar(2000),
      @Tcols nvarchar(2000),
      @Sql nvarchar (max)
    select @cols = stuff ((
          Select distinct '], ['+ModelName + '  ' + CombustorName
           from CombustorFuel cf
           join Model m on cf.modelid = m.modelid
           join Combustors cb on cf.CombustorID = cb.CombustorID
           where cf.CombustorID > 0
           for XML Path('')
          ),1,2,'')+']'
    Set @Tcols = replace(@Cols, ']', '] int')
    --Print @Tcols   
    --Print @Cols
    Set @Sql = 'Select GasLiquid, FuelType, '+ @Cols +'
    from
     Select GasLiquid, FuelType, ModelName+ ''  '' +CombustorName ModelCombustor, CombFuelStatus+''- ''+CombFuelNote CombFuelStatusNote
      from Frames f
      join Family fa on f.Frameid = fa.frameid
      join Model m on fa.FamilyID = m.FamilyID
      join CombustorFuel cf on m.Modelid = cf.modelid
      Join Combustors c on cf.CombustorId = c.CombustorID
      join FuelTypes ft on cf.FuelTypeID = ft.FuelTypeID
      where cf.CombustorFuelID > 0
        and CombustorName <> ''''
     ) up
    Pivot
     (max(CombFuelStatusNote) for ModelCombustor in ('+ @Cols +')) as pvt
    order by FuelType'
    exec (@Sql)

    Then again, a good reporting tool should be able to do dynamic pivot on its own, because dynamic pivoting is a presentation feature.
    SSRS Supports dynamic columns: Displaying Dynamic Columns in SSRS Report
    SQL Reporting Services with Dynamic Column Reports
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
    Displaying and reading are two very different things.
    #1) SSRS Needs a fixed field list on the input side to know what what to make available in the designer.
    #2) SSRS cant read "exec (@Sql)" out of a proc, even if there is a fixed number of columns (at
    least it can't use it to auto build the field list from the proc)
    I use dynamic SQL in my report procs on a fairly regular basis and I've found it easiest to simply dump
    the results of my dynamic sql into a temp table at the end of the procs and then select from the temp table.
    Basically, Erland is correct. Stop trying to pivot in the query and let SSRS (or whatever reporting software you're using) handle it with a Martix.
    Jason Long

  • Cursor with nested query in stored procedure problem

    Hello
    I'm trying to declare the folowing (example) cursor in a stored procedure in Oracle 8i:
    CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    The nested part "(SELECT d.DUMMY FROM dual)" is not alowed, while the same query runs outside the stored procedure. Can someone explain why this is not alowed and how to solve the problem whitout rewriting the query?
    Tom

    When i run the same code in SQL plus:
    SQL> declare
    2 CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    3 begin
    4 null;
    5 end;
    6 /
    CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
    FOUT in regel 2:
    .ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + mod not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string>
    ORA-06550: line 2, column 66:
    PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
    ; return returning and or
    Different versions of Oracle?

  • Can we query a stored procedure results as an SQL Table ?

    Hi,
    Can we query a results from the results of a stored procedure returning a result set either as cursors or as PL/SQL Table like what we do like this
    select * from <tablename>
    select * from (select * from tablename) alias. instead of this, can we do like this
    select * from (results of stored procedure) alias.
    Please Provide any Help.

    I agree. Pipelined Table Functions are the way to go.
    Docs at http://tahiti.oracle.com
    Working demos in Morgan's Library at www.psoug.org under Pipelined Table Functions.

  • Disconnected rowset CachedRowSet from a select inside stored procedure?

    Hello everyone
    I am using CachedRowSet returning it from a parameterised select statement and it works fine.
    If I put the same select statement into a simple read-only stored procedure then I get this exception: "A result set was generated for update".
    I am not trying to update the rowset in my code.
    I tried to make the CachedRowSet to be read-only but it does not help, same error.
    Question 1 : can a stored procedure returning a single result-set be called to populate a read-only CachedRowSet? (in a similar fashion to a CallableStatement prepareCall method with input/output parameters).
    Question 2: in general is using CachedRowSet, WebRowSet, FilteredRowSet (disconnected) and JDBCRowSet (connected) something to be encouraged for future develpment or are they deprecated, or replaced by something else/better??
    thank you very much in advance

    Thank you for the initial bite.
    This is for Microsoft SQL Server 2008 using Microsoft JDBC driver, type 4.0.
    The T-SQL stored procedure has a single select statement in it - see inside code.
    Below is the Java 6 source code (including the Java import statements, many unused at the moment), apologies for poor indendation, its a cut and paste problem.
    // start of Java code
    import java.io.*;
    import java.sql.*;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import com.microsoft.sqlserver.jdbc.*;
    import com.microsoft.sqlserver.jdbc.SQLServerDriver.*;
    import com.microsoft.sqlserver.jdbc.SQLServerDriver;
    import java.math.BigDecimal;
    import com.sun.rowset.CachedRowSetImpl;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.sql.Connection;
    import java.sql.Date;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.Timestamp;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.util.HashMap;
    import javax.sql.rowset.CachedRowSet;
    import javax.sql.rowset.spi.SyncProviderException;
    import javax.sql.rowset.spi.SyncResolver;
    public class JdbcRowSetTesting
    public static void main(String[] args)
      String connectionUrl =
      "jdbc:sqlserver://ABCDE-SERVER:1433;" +
       "databaseName=SecurityTransaction;integratedSecurity=false;user=somedbuser;password=somesortofpassword";
      Connection conn = null;
      Statement sqlstmt = null;
      ResultSet rs = null;
      CachedRowSet crs = null;
       try
      conn = DriverManager.getConnection(connectionUrl);
      System.out.println("inside try block, connected");
      conn.setAutoCommit(false);
      crs = new CachedRowSetImpl();
      crs.setUrl(connectionUrl);
      crs.setReadOnly(true);
      crs.setType(ResultSet.TYPE_FORWARD_ONLY);
      crs.setConcurrency(ResultSet.CONCUR_READ_ONLY);
      System.out.println("inside try block, connected to CachedRowSet URL"); 
    // this works fine:
      crs.setCommand("select ADDRESSID, COUNTRY, POSTCODE, STATE, ADDRESS1, ADDRESS2, ADDRESS3, ADDRESS4, CREATEDBY, CREATEDDATE, UPDATEDBY, UPDATEDDATE from dbo.address where ADDRESSID > ?;");
    -- this does not work - the SP has  the same SELECT as above inside it:
      crs.setCommand("{ call dbo.p_testCachedJDBCRowSet (?) }");
      crs.setInt(1, 10);
      crs.execute();
       while (crs.next())
      System.out.println("" + crs.getInt("ADDRESSID") + " " +
      crs.getString("ADDRESS1"));
       catch (Exception e)
      System.out.println("inside catch block, calling Exception printStackTrace(); method now:");
      e.printStackTrace();
       finally
      System.out.println("inside finally block");
       if (rs != null) try { rs.close(); } catch(Exception e) { e.printStackTrace(); }
       if (sqlstmt != null) try { sqlstmt.close(); } catch(Exception e) { e.printStackTrace(); }
       if (conn != null) try { conn.close(); } catch(Exception e) { e.printStackTrace(); }
    return;
    // end of Java source code

  • A query in Stored Procedure

    Hi ,
    I am using EXECUTE IMMEDIATE to execute a DDL Statement inside a Stored Procedure .
    But i am unable to see this table , please tell me why .
    create or replace procedure NAmes
    is
    begin
    EXECUTE IMMEDIATE 'CREATE TABLE execute_table (col1 VARCHAR(10))';
    commit;
    end;
    Procedure created.

    Hi,
    user10503747 wrote:
    I am using EXECUTE IMMEDIATE to execute a DDL Statement inside a Stored Procedure .Why? Performing DDL in strored procedures is usually not the best way to do things in Oracle.
    Whenever you have a problem, post a compete test script that people can use to re-create the problem and test their ideas. The CREATE TABLE statement that you posted was a good start; add code to show how you ran it, and what you did to see if it worked or not.
    For example:
    create or replace procedure NAmes
    is
    begin
        EXECUTE IMMEDIATE 'CREATE TABLE execute_table (col1 VARCHAR(10))';
        commit;   -- Not needed.  DDL automatically causes COMMIT
    end;
    SHOW ERRORS
    PROMPT     =====  Before Running Names Procedure  =====
    DESCRIBE     execute_table
    EXEC  names;
    PROMPT     =====  After Running Names Procedure  =====
    DESCRIBE     execute_tableThis worked fine for me in Oracle 10.2.0.1.0 and SQL*Plus 10.2. Output:
    Procedure created.
    No errors.
    =====  Before Running Names Procedure  =====
    ERROR:
    ORA-04043: object execute_table does not exist
    PL/SQL procedure successfully completed.
    =====  After Running Names Procedure  =====
    Name                                      Null?    Type
    COL1                                               VARCHAR2(10)What are you doing different?
    Did you get any error messages?
    Are you creating the procedure in one schema, and running it in another?
    Did you call the names procedure from another procedure?
    Don't make people guess. Guessing is not the best way to solve problems.

  • Query on Stored Procedure for UDF's

    Hi guys,
    I  have created 3 UDF's  T0.[U_LR_Receipt], T0.[U_Removal_Time], T0.[U_Removal_Date]
    at header level for the marketing documents.I  want the invoice to be added only if the above  fileds is entered  or else it has to show the error message.
    to acheive this i have created a  stored procedure in SBO_SP_TransactionNotification for U_LR_Receipt.
    But i want to know whether we can add two more procedures in  the same or else i need a  single query for the 3 fields.
    Below is the  code i used ,
    if @object_type = '13' and @transaction_type IN ('A','U')
    begin
    declare @LRRECEIPT NVARCHAR(10)
    set @LRRECEIPT = (select isnull(T0.U_LR_Receipt,0) from OINV T0 where T0.DocEntry = @list_of_cols_val_tab_del)
    If (@LRRECEIPT = 0)
    begin
    select @error = 1
    select @error_message = 'You cannot post the INVOICE  without LR Receipt No'
    End
    End
    Thanks in advance,
    Regards,
    Vamsi.

    Hi Vamsi,
    Give this a go.
    Kind Regards,
    Adrian
    if @object_type = '13' and (@transaction_type= 'A' or @transaction_type= 'U')
    begin
                    if (select count(1) from OINV where DocEntry = @list_of_cols_val_tab_del and (U_LR_Receipt IS NULL or U_Removal_Time IS NULL or U_Removal_Date IS NULL)) > 0
                                    begin
                                                    select @error = 1
                                                    select @error_message = N'You cannot post the Invoice without the LR Receipt No, Removal Time or Removal Date'
                                    end
    end

  • How to use &APP_ID. inside stored procedure.

    Hello, I have created one stored procedure. I am calling it from my process code. I want to use so many page variables like &APP_ID. I do not want to pass it as argument. Is it possible to use those variables without passing it in to procedure.? (&page_id. and also some application level variables )
    Any help is appreciated.
    Thank you.

    Ashif:
    The APEX documentation describes in detail the various ways of referencing APEX session state.
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/concept.htm#BEICHBBG
    Local variables declared in your process block are not available in APEX' session state. Hence you cannot refence such variables in a stored procedure.
    Varad

  • SELECT QUERY USING STORED PROCEDURE

    Hi,
    I am using stored procedure in package, i need to execute select statement using
    stored procedure.
    regards,
    p.kumaran

    ? not framed properly i think so if u dnt mind plz check it out once
    if u wnt to invoke a proc from package 2 ways r there
    1) execute pac_name.proc_name[(arg_list)];
    2) pl/sql
    [declare]
    begin
    pac_name.proc_name[(arg_list)];
    end;
    /

  • Commit inside stored procedure

    If you call a procedure from another procedure and issue COMMIT, then you commit not just inner stored procedure, but also outside procedure. Am I right? Can we make SP smarter and commit only statement in inner SP?

    But bear in mind that a rollback will have a similar effect. A rollback of parent transaction will not undo the work done in the autonomous transaction. That might be a issue to watch out for if you wanted to undo all the changes in the event of an error.

Maybe you are looking for

  • S_ALR_87012093 (Vendor) e S_ALR_87012186 (Customer) x Business Area

    Hi, I executed the standards reports: S_ALR_87012093 (Vendor business) and S_ALR_87012186 (Customer Sales), in the first screen in "Hide Dinamic Selection" I put "Business Area", but when the reports ran, nothing filter by business area was consider.

  • Macbook pro went dark

    My macbook pro's screen went dead while using: safari, charge iPhone, sync iPad.  Disconnected  everything including the screen, the laptop remains dead, power supply works, neither computer no screen on laptop will boot.  Is this rest in peace time?

  • N8 FM Transmitter No Longer Transmits internet rad...

    i have had my N8 for over a year now, and until the recent update, I use to be able to transmit the internet radio thru the N8 FM transmitter, Now when i try and use it as soon as I turn on the transmitter, internet radio stops, then when i try to cl

  • InovcationService not returning all Members in the Map

    Hello, I am running my application with a near cache scheme. The distributed cache is on a seperate JVM - i have a tool that will allow me to view the Front and Back sizes using JMX, i can also view what is in the Front vs. the back cache using the I

  • ORA-07202 sltln: invalid parameter to sltln.using

    OS:Red Hat Linux 5 DB :11.2.0.2 i am getting this error while creating 11g DB using DBCA ORA-07202 sltln: invalid parameter to sltln.using dbca to create