Nested Tables select query soooooo slow

I know that varrays are supposed to be used for small arrays. But, we are comparing nested tables to varrays and two table joins. Nested table query is unimaginably ,unacceptably slow.
Is there anybody else out there who experienced the same thing. Are there ways to speed up the select queries.(besides indexes)

If you try to use nested sql statement. Please be sure to setup the index to some specific tables inside oracle
Doing this will speed up your performance about 5 ~ 9 times original.
[email protected]

Similar Messages

  • SELECT query very slow, need suggestion.

    Dear all,
    Below stmt was coded in my report program.
    It was taking around 14 seconds in development system. The days in s_datum was just 1 or 2 days max.
    But when the same was transferred to test system, it is taking almost 10 minutes, though it we gave just 1 day.
      SELECT * FROM likp INTO TABLE i_likp                  
            WHERE erdat IN s_datum AND wadat_ist > '00000000' 
              AND lfart <> 'EL'                               
              AND vstel not in s_vstel.
    Some of you might suggest to make SELECT query with only s_datum, but i tried it in dev system, it was taking almost 22 secs with only s_datum.  I thought it could be more worse in test system so, did not move that idea.
    Can some one please suggest me why it is happening so.

    Hi,
    The difference, as I suppose you know, happens because LIKP probably has much more records in production than in the development system.
    You must think what is selective in your WHERE clause:
    - erdat in s_datum is selective if you are are only using one day
    - wadat_ist GE '00000000' is not selective (all deliveries with goods issue fulfill that condition)
    - lfart NE 'EL' probably is not selective
    - vsten not in s_vstel probably is not selective
    So in the end only erdat is selective. There is no index in LIKP by ERDAT, so if you really want to make it faster you would need an index by ERDAT.
    Still, if you are only making one SELECT (not inside a loop) I wouldn't expect that to take more than 10 minutes.
    I would measure the program with SE30 to make sure it is really the SELECT that is taking so much time (post here the results), and if it really is the select post here the explain plan.
    By the way, if you need to know all goods issues for the last day I would use change pointers instead.
    Hope this helps,
    Rui Dantas

  • Internal tables & select query for clasical report

    hello all,
           i am a novice in ABAP.i need to retrive data from 4 DB tables to do a classical report. i declared internal tables as below and then retrieved the data as per the below select statements. is there any other way in which i can do the same with a comparitively lesser amt of code.
    data: begin of i_vbak occurs 0,
          vbeln like vbak-vbeln,
          kunnr like vbak-kunnr,
          waerk like vbak-waerk,
          end of i_vbak.
    data: begin of i_vbap occurs 0,
          vbeln like vbap-vbeln,
          kwmeng like vbap-kwmeng,
          posnr like vbap-posnr,
          vrkme like vbap-vrkme,
          netpr like vbap-netpr,
          end of i_vbap.
    data: begin of i_lips occurs 0,
          vbeln like lips-vbeln,
          vgpos like lips-vgpos,
          vrkme like lips-vrkme,
          lfimg like lips-lfimg,
          end of i_lips.
    data: begin of i_vbep occurs 0,
          vbeln like vbep-vbeln,
          posnr like vbep-posnr,
          edatu like vbep-edatu,
          end of i_vbep.
    data: begin of i_out occurs 0,
          kunnr like vbak-kunnr,
          vbeln like vbak-vbeln,
          kwmeng like vbap-kwmeng,
          netpr like vbap-netpr,
          waerk like vbak-waerk,
          vrkme like vbap-vrkme,
          lfimg like lips-lfimg,
          posnr like vbep-posnr,
          edatu like vbep-edatu,
          end of i_out.
          RETRIVING THE DATA INTO INTERNAL TABLE                         *
    select vbeln kunnr waerk from vbak into table i_vbak where kunnr in
    s_kunnr and vbeln in s_vbeln.
    select vbeln kwmeng posnr vrkme netpr from vbap into table i_vbap for
    all entries in i_vbak where vbeln = i_vbak-vbeln.
    select vbeln vgpos vrkme lfimg from lips into table i_lips for all
    entries in i_vbak where vbeln = i_vbak-vbeln and vgpos in s_vgpos.
    select vbeln posnr edatu from vbep into table i_vbep for all entries in
    i_vbak where vbeln = i_vbak-vbeln.
    <b>Points are guaranteed for good answers.</b>
    Thanks in advance
    seenu

    Hi,
    If u will use in ALV means  how many tables u want u can put it. After that u can maintain one internal table that's enough. Afterthat  put select queries after that display the internal table fileds.
    If u will ALV  report means u have to code same coding for every report slight changes only there.
    Herewith i am sending sample ALV REPORT it is useful for u.
    REPORT CODING:
    REPORT  YMS_COLOURALV NO STANDARD PAGE HEADING.
    TYPE-POOLS: SLIS, ICON.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA: BEGIN OF IMARA OCCURS 0,
              LIGHT(4) TYPE C,
              MATNR TYPE MARA-MATNR,
              MTART TYPE MARA-MTART,
              MAKTX TYPE MAKT-MAKTX,
              COLOR_LINE(4) TYPE C,
              TCOLOR TYPE SLIS_T_SPECIALCOL_ALV,  "cell
          END OF IMARA.
    DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      PERFORM WRITE_REPORT.
    Get_Data
    FORM GET_DATA.
      WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
          IMARA-MATNR = 'ABC'.
          IMARA-MTART = 'ZCFG'.
          IMARA-MAKTX = 'This is description for ABC'.
      APPEND IMARA.
      WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
          IMARA-MATNR = 'DEF'.
          IMARA-MTART = 'ZCFG'.
          IMARA-MAKTX = 'This is description for DEF'.
      APPEND IMARA.
      WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
          IMARA-MATNR = 'GHI'.
          IMARA-MTART = 'ZCFG'.
          IMARA-MAKTX = 'This is description for GHI'.
      APPEND IMARA.
      LOOP AT IMARA.
        IF SY-TABIX = 1.
          IMARA-COLOR_LINE = 'C410'.     " color line
        ENDIF.
        IF SY-TABIX = 2.                "  color CELL
          CLEAR XCOLOR.
          XCOLOR-FIELDNAME = 'MTART'.
          XCOLOR-COLOR-COL = '3'.
          XCOLOR-COLOR-INT = '1'.       " Intensified on/off
          XCOLOR-COLOR-INV = '0'.
          APPEND XCOLOR TO IMARA-TCOLOR.
        ENDIF.
        MODIFY IMARA.
      ENDLOOP.
    ENDFORM.                    "get_data
    WRITE_REPORT
    FORM WRITE_REPORT.
      DATA: LAYOUT TYPE  SLIS_LAYOUT_ALV.
      LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
      LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
      PERFORM BUILD_FIELD_CATALOG.
    CALL ABAP LIST VIEWER (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          IS_LAYOUT   = LAYOUT
          IT_FIELDCAT = FIELDCAT
        TABLES
          T_OUTTAB    = IMARA.
    ENDFORM.                    "write_report
    BUILD_FIELD_CATALOG
    FORM BUILD_FIELD_CATALOG.
      DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
      CLEAR: FIELDCAT. REFRESH: FIELDCAT.
      CLEAR: FC_TMP.
      FC_TMP-REPTEXT_DDIC    = 'Status'.
      FC_TMP-FIELDNAME  = 'LIGHT'.
      FC_TMP-TABNAME   = 'IMARA'.
      FC_TMP-OUTPUTLEN  = '4'.
      FC_TMP-ICON       = 'X'.
      APPEND FC_TMP TO FIELDCAT.
      CLEAR: FC_TMP.
      FC_TMP-REPTEXT_DDIC    = 'Material Number'.
      FC_TMP-FIELDNAME  = 'MATNR'.
      FC_TMP-TABNAME   = 'IMARA'.
      FC_TMP-OUTPUTLEN  = '18'.
      APPEND FC_TMP TO FIELDCAT.
      CLEAR: FC_TMP.
      FC_TMP-REPTEXT_DDIC    = 'Material Type'.
      FC_TMP-FIELDNAME  = 'MTART'.
      FC_TMP-TABNAME   = 'IMARA'.
      FC_TMP-OUTPUTLEN  = '10'.
      APPEND FC_TMP TO FIELDCAT.
      CLEAR: FC_TMP.
      FC_TMP-REPTEXT_DDIC    = 'Material'.
      FC_TMP-FIELDNAME  = 'MAKTX'.
      FC_TMP-TABNAME   = 'IMARA'.
      FC_TMP-OUTPUTLEN  = '40'.
      FC_TMP-EMPHASIZE = 'C610'.   " color column
      APPEND FC_TMP TO FIELDCAT.
    ENDFORM.                    "build_field_catalog
    Thanks,
    Shankar

  • Select * query is slow on one particular table

    Hi ,
    I am using forms and reports of AppServer 10g,one particular form accesing one table ...The select * from statement on that table is slow.Any amendmends to be taken care of at the tablespace level??
    Help needed urgent...
    Regards,
    Ashlee

    Hi,
    This is a general type of question. please be specific. Golden Thumb rule is that don't use '*", instead use the column names. Analyze the table and take a execution plan and check for index usage .
    Please give the problem statement also so that we can help you.

  • Internal table select query

    Hi Experts,
    I have one internal table with some values like
    PLNNR           PLNAL                ZAEHL
    5000021            01                      01
    5000021            01                      02
    5000021            01                      03
    5000021            01                      04
    5000021            01                      05
    I want to fetch greatest value from ZAEHL column.
    Can any one pls help me.
    Thanks,
    Madhu.

    Hi Gordan,
    I am getting error like " itab is not defined in the ABAP Dictionary as a table , projection view or database view."
    Can you pls guide me .
    Thanks,
    Kaladhar.

  • Nested Tables and Advanced Queues- Please Help.

    How do i work with NestedTable type and Advanced Queue.
    I have done the following
    I have Oracle 8.1.7 enterprise edition.
    create type myType as TABLE OF varchar(32);
    create type myObject as OBJECT (
    id int,
    myt myType);
    DECLARE
    BEGIN
    dbms_aqadm.create_queue_table(
    queue_table => 'my_queue_table',
    multiple_consumers => TRUE,
    queue_payload_type => 'myObject',
    compatible => '8.1.3'
    END;
    The Nested Table and Object are created successfully.
    but the queue is not created.
    I get the following message.
    DECLARE
    ERROR at line 1:
    ORA-22913: must specify table name for nested table column or
    attribute
    ORA-06512: at "SYS.DBMS_AQADM_SYS", line 2012
    ORA-06512: at "SYS.DBMS_AQADM", line 55
    ORA-06512: at line 3
    I know how to specify the nested table storage clause for
    create table statement, but there is no provision for
    it in the create_queue_table procedure.
    Any help will be greately appriciated.
    i have already created and tested aqs with simple data types,
    also i have created simple tables with nested table type
    elements.
    but the combo of Nested tables and AQ is not working.
    thanks in advance.

    Hi Francois. Thank you very much for your reply, but it seems that i still get errors. So let me tell what i have done.
    As you suggested me: i have done a block based on a sub-query for the nested-table:
    'select courses from department where name= :department.name'.
    In the master block(department) i have the when-new-record-instance trigger:
    Declare
    LC$Req varchar2(256);
    Begin
    LC$Req := '(select ns.courses from table
    ( select courses from department where name = ''' || :DEPARTMENT.name || ''' ) ns )';
    Go_block('block11');
    Clear_Block ;
    Set_Block_Property( 'block11', QUERY_DATA_SOURCE_NAME, LC$Req ) ;
    Execute_query ;
    End ;
    Now the errors i receive, this time in the runtime mode are:
    - FRM-41380: Cannot set the blocks query data source
    -FRM-41003: This function cannot be performed here.
    Since it seems that you know how to work with the nested table i would really appreaciate your help. I am new in the nested table and if you could give an ex with my tables it would be great.
    Thank you in advance.

  • Nested Tables and Forms 9i-please help

    Hi
    i have the folowing example of a nested table:
    CREATE TYPE CourseList AS TABLE OF VARCHAR2(10) -- define TABLE type
    CREATE TYPE Student AS OBJECT ( -- create object
    id_num INTEGER(4),
    name VARCHAR2(25),
    address VARCHAR2(35),
    status CHAR(2),
    courses CourseList) -- declare nested table as attribute
    CREATE TYPE Course AS OBJECT (
    course_no NUMBER(4),
    title VARCHAR2(35),
    credits NUMBER(1));
    CREATE TYPE CourseList AS TABLE OF Course;
    CREATE TABLE department (name VARCHAR2(20),
    director VARCHAR2(20),
    office VARCHAR2(20),
    courses CourseList)
    NESTED TABLE courses STORE AS courses_tab;
    In Forms i have created a data block based on table department and for managing the nested table courses_tab i found out that i should use a stored procedure:
    PROCEDURE procedure_nest (c_c out courses_tab%rowtype) IS
    c_c courselist;
    BEGIN
    select c.name, c.director,office into :department.name, :department.director,
    :department.office from department c , table
    (select n.courses from department n where c.name =n.name and rownum<=1);
    END;
    compil error:
    error 999 at line 1, column 35
    implemntation restriction (may be temporary) ADT or schema level
    collection not supported at client side with non-OCI mode.
    i really would like to know what shall i do to use and manage the nested table in forms.
    Thank you very much

    Hi Francois. Thank you very much for your reply, but it seems that i still get errors. So let me tell what i have done.
    As you suggested me: i have done a block based on a sub-query for the nested-table:
    'select courses from department where name= :department.name'.
    In the master block(department) i have the when-new-record-instance trigger:
    Declare
    LC$Req varchar2(256);
    Begin
    LC$Req := '(select ns.courses from table
    ( select courses from department where name = ''' || :DEPARTMENT.name || ''' ) ns )';
    Go_block('block11');
    Clear_Block ;
    Set_Block_Property( 'block11', QUERY_DATA_SOURCE_NAME, LC$Req ) ;
    Execute_query ;
    End ;
    Now the errors i receive, this time in the runtime mode are:
    - FRM-41380: Cannot set the blocks query data source
    -FRM-41003: This function cannot be performed here.
    Since it seems that you know how to work with the nested table i would really appreaciate your help. I am new in the nested table and if you could give an ex with my tables it would be great.
    Thank you in advance.

  • Nested tables.... Please help

    Hi Friends,
    I have some strange issues when I am trying to create a nested dynamic table with SAP DATA in Adobe Designer.
    In the context, under the MAIN node
    I had dragged the header table. Under the header table I had dragged the item table and had created a WHERE condition to link the HEADER and ITEM table.
    Now my layout is pretty complicated..
    I want to result to be as below:
    header row.... with 0001 Customer name
    item row with 0001 0010 price qty
    0001 0020 price qty
    0001 0030 price qty
    header row... field4
    (field4 from the header table has to be displayed after the item table has generated all the items and this process should repeat for all header data)
    My design in layout is as below
    subform1 for headerdata
    ( set as positioned and has set to 'Repeat form for each data item')
    headerdata fields for subform1 (field1, field2, field3)
    subform2 for itemdata
    (set as folowed)
    subform3 for itemdata
    (set as positioned, 'Allow page breaks within content' and had set 'Repeat form for each data item')
    itemdata fields in subform3
    subform4 for headerrow field4
    but when I activated and execute the form, the result was wrong.
    The result should be like below...
    |->field1, field2, field3
    |--->field1 charge111
    |--->field1 charge211
    |-> field4
    |->field2
    |--->field2 charge122
    |--->field2 charge222
    |-> field4
    but it is printed like below and field4 is overlapped with the item rows if the item rows are more...
    DATA
    |->field1 field2 field3
    |--->field1 charge111 This inner table is overlapping the subform4 for each item
    |--->field1 charge211
    |
    |->field1 field2 field3
    |--->field1 charge121 This inner table is overlapping the subform4 for each item
    |--->field1 charge221
    2) If I have more item data, all the item rows are overlapped with the field4 (which I had explained in my layout) and the item rows are not moved to the next page, but still it is continued in the same page, meaning that if the page can fill 20 lines and my item row are more than 20 lines, 20 lines are printed and the remaining items are not moved to the next page... it is invisible...
    How can I solve this issue?
    Please help me
    Thanks in advance.
    Jaffer Ali.S

    Hi Francois. Thank you very much for your reply, but it seems that i still get errors. So let me tell what i have done.
    As you suggested me: i have done a block based on a sub-query for the nested-table:
    'select courses from department where name= :department.name'.
    In the master block(department) i have the when-new-record-instance trigger:
    Declare
    LC$Req varchar2(256);
    Begin
    LC$Req := '(select ns.courses from table
    ( select courses from department where name = ''' || :DEPARTMENT.name || ''' ) ns )';
    Go_block('block11');
    Clear_Block ;
    Set_Block_Property( 'block11', QUERY_DATA_SOURCE_NAME, LC$Req ) ;
    Execute_query ;
    End ;
    Now the errors i receive, this time in the runtime mode are:
    - FRM-41380: Cannot set the blocks query data source
    -FRM-41003: This function cannot be performed here.
    Since it seems that you know how to work with the nested table i would really appreaciate your help. I am new in the nested table and if you could give an ex with my tables it would be great.
    Thank you in advance.

  • Nested table collection in select query "in clause" taking long time

    create or replace type t_circuitids is table of varchar2(100);
    --Below anonymous block keeps on running and never ends
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (v_circuitid));
    END;
    --I got the issue, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" which is used in above code is responsible for this.
    --Same code works fine in Development and Test environments, But in prod it keeps on running
    --I solved this issue by creating a temp table, loading all values in collection into the temp table and using that temp table in "in clause"    "
    --Can any one answer why its behaving like this when i use collection in where clause?
    --I am using Oracle 9i

    Below is the code i used
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (ccard(v_circuitid)));
    END;
    And got below error
    ORA-06550: line 27, column 5:
    PL/SQL: ORA-00906: missing left parenthesis
    ORA-06550: line 24, column 4:
    PL/SQL: SQL Statement ignored

  • Querying Nested Tables from BO

    Hi,
    I have a nested table [VA_GT_HC_ASIA_SGP ] in Oracle. The Inner Object in the nested table has got 4 columns, which has to be displayed in the WebI Report.
    Hece I created the table as derived table in Universe by the below query.
    select a.COL1, b.COL2, b.COL3, b.COL4, b.COL5 from VA_GT_HC_ASIA_SGP a, Table(a.OB_GT_HC_MAINT_INFO) b
    But performance is very slow. Please advice if there exists a better way to do this.
    Best Regards,
    Anu

    The Query is:-SELECT A.ID, A.NAME, A.COMB, B.C1,B.C2, B.C3  FROM NT_KFD_RFT_TEST_DATE A, TABLE(OB_KFD_RFT_DATA) B
    Nested Table structure Example:-
    ID       NAME    COMB   OB_KFD_RFT_DATA
    01      TEST     ALL    
    The inner table (OB_KFD_RFT_DATA) structure is
    C1      C2        C3
    23.5   56.7   78.9
    00.9   76.9   53.3
    12.4   33.4   23.2
    Here outer record is 01 TEST ALL, and inner record is the 3 row decimal numbers.
    In Universe, I need to create Objects from C1,       C2,      C3 columns.
    Currently i'm doing it with derived table (by running above query). Is there any other option to do it?
    Thanks,
    Anu

  • Need help in optimisation for a select query on a large table

    Hi Gurus
    Please help in optimising the code. It takes 1 hr for 3-4000 records. Its very slow.
    My Select is reading from a table which contains 10 Million records.
    I am writing the select on large table and Retrieving the values from large tables by comparing my table which has 3-4 k records.
    I am pasting the code. please help
    Data: wa_i_tab1 type tys_tg_1 .
    DATA: i_tab TYPE STANDARD TABLE OF tys_tg_1.
    Data : wa_result_pkg type tys_tg_1,
    wa_result_pkg1 type tys_tg_1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1 from
    /BIC/PZREB_SDAT *******************THIS TABLE CONTAINS 10 MILLION RECORDS
    into CORRESPONDING FIELDS OF table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE***************CONTAINS 3000-4000 RECORDS
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE-/BIC/ZLITEM1.
    sort RESULT_PACKAGE by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    sort i_tab by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    loop at RESULT_PACKAGE into wa_result_pkg.
    read TABLE i_tab INTO wa_i_tab1 with key
    /BIC/ZREB_SDAT =
    wa_result_pkg-/BIC/ZREB_SDAT
    AGREEMENT = wa_result_pkg-AGREEMENT
    /BIC/ZLITEM1 = wa_result_pkg-/BIC/ZLITEM1.
    IF SY-SUBRC = 0.
    move wa_i_tab1-/BIC/ZSETLRUN to
    wa_result_pkg-/BIC/ZSETLRUN.
    wa_result_pkg1-/BIC/ZSETLRUN = wa_result_pkg-/BIC/ZSETLRUN.
    modify RESULT_PACKAGE from wa_result_pkg1
    TRANSPORTING /BIC/ZSETLRUN.
    ENDIF.
    CLEAR: wa_i_tab1,wa_result_pkg1,wa_result_pkg.
    endloop.

    Hi,
    1) RESULT_PACKAGE internal table contains any duplicate records or not bassed on the where condotion like below
    2) Remove the into CORRESPONDING FIELDS OF table instead of that into table use.
    refer the below code is
    RESULT_PACKAGE1[] = RESULT_PACKAGE[].
    sort RESULT_PACKAGE1 by /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    delete adjustant duplicate form RESULT_PACKAGE1 comparing /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1
    from /BIC/PZREB_SDAT
    into table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE1
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE1-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE1-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE1-/BIC/ZLITEM1.
    and one more thing your getting 10 million records so use package size in you select query.
    Refer the following link also For All Entry for 1 Million Records
    Regards,
    Dhina..
    Edited by: Dhina DMD on Sep 15, 2011 7:17 AM

  • Sinlge select query in diff schemas for same table(Indentical Structure)

    Scenario :
    Table XYZ is created in Schema A
    After an year, the old data from the previous year would be moved to different schema. However in the other schema the same table name would be used.
    For eg
    Schema A contains table XYZ with data of 2012 yr
    Schema B contains table XYZ with data of 2011 yr
    Table XYZ in both the schemas have identical structure.
    So can we fire a single select query to read the data from both the tables in effective way.
    Eg select * from XYZ where date range between 15-Oct-2011 to 15-Mar-2012.
    However the data resides in 2 different schema altogether.
    Creating an view is an option.
    But my problem, there is ORM layer(either Hibernate or Eclipse Top Link) between the application and the database.
    So the queries would be formed by the ORM layer and are not hand generated.
    So i cannot use view.
    So is there any option that would allow me to use single query on different schema's ?

    Hi,
    970773 wrote:
    Scenario :
    Table XYZ is created in Schema A
    After an year, the old data from the previous year would be moved to different schema. However in the other schema the same table name would be used.
    For eg
    Schema A contains table XYZ with data of 2012 yr
    Schema B contains table XYZ with data of 2011 yr
    Table XYZ in both the schemas have identical structure.
    So can we fire a single select query to read the data from both the tables in effective way.That depends on what you mean by "effective".
    Eg select * from XYZ where date range between 15-Oct-2011 to 15-Mar-2012.
    However the data resides in 2 different schema altogether.You can do a UNION, so the data from the two years appears together. The number of actual tables may make the query slower, but it won;t change the results.
    Given that you have 2 tables, the fact that they are in different schemas doesn't matter. Just make sure the user running the query has SELECT privileges on both of them.
    Creating an view is an option.Is it? You seem to say it is not, below.
    But my problem, there is ORM layer(either Hibernate or Eclipse Top Link) between the application and the database.
    So the queries would be formed by the ORM layer and are not hand generated.
    So i cannot use view.So creating a view is not an option. Or is it?
    So is there any option that would allow me to use single query on different schema's ?Anything that you can do with a view, you can do with sub-queries. A view is merely a convenience; it just saves a sub-query, so you don't have to re-code it every time you use it. Assuming you have privilges to query the base tables, you can always avoid using a view by repeating the query that defines the view in your own query. It will not be any slower

  • Select from nested table

    Hi,
    I create following types and table:
    CREATE OR REPLACE TYPE obj_query AS OBJECT
    (emp_id NUMBER(6)
    ,emp_first VARCHAR2(20)
    ,emp_last VARCHAR2(25));
    CREATE OR REPLACE TYPE tab_query AS TABLE OF obj_query;
    CREATE TABLE queryEmp
    (id_row NUMBER
    ,beginTrans VARCHAR2(15)
    ,queryA VARCHAR2(100)
    ,resultEmp tab_query)
    NESTED TABLE resultEmp
    STORE AS nested_queryEmp;
    I would like the output of the table queryEmp like this:
    id_row beginTrans queryA emp_id emp_first emp_last
    1 15:00 Select1 100 Joe King
    101 John Queen
    2 15:10 Select2 100 Leo King
    101 Mett Queen
    But Can I get this result with only SQL SELECT statement from this table?
    I don't want to use PL/SQL, only SELECT in SQL*Plus.
    Thank you
    I'm sorry but output looks so bad.
    So, I want to get the one row of id_row, beginTrans, queryA and all rows of nested table dmlStats to this "main" row and so on.
    But not in PL/SQL
    I hope, you understand me.
    Thanks
    Edited by: user9357436 on 2.11.2011 5:18
    Edited by: user9357436 on 2.11.2011 5:25

    Arvind Ayengar wrote:
    Can you please explain things in details, and just ensure you are in the correct forum.Is this reply directed at me or the OP?

  • When selecting a row from a view with a nested table I want just ONE entry returned

    Does a nested table in a view "EXPLODE" all values ALWAYS no matter the where clause for the nested table?
    I want to select ONE row from a view that has columns defined as TYPE which are PL/SQL TABLES OF other tables.
    when I specify a WHERE clause for my query it gives me the column "EXPLODED" with the values that mathc my WHERE clause at the end of the select.
    I dont want the "EXPLODED" nested table to show just the entry that matches my WHERE clause. Here is some more info:
    My select statement:
    SQL> select * from si_a31_per_vw v, TABLE(v.current_allergies) a where a.alg_seq
    =75;
    AAAHQPAAMAAAAfxAAA N00000 771 223774444 20 GREGG
    CADILLAC 12-MAY-69 M R3
    NON DENOMINATIONAL N STAFF USMC N
    U
    E06 11-JUN-02 H N
    05-JAN-00 Y Y
    USS SPAWAR
    353535 USS SPAWAR
    SI_ADDRESS_TYPE(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NUL
    L, NULL)
    SI_ADDRESS_TAB()
    SI_ALLERGY_TAB(SI_ALLERGY_TYPE(69, 'PENICILLIN', '11-JUN-02', NULL), SI_ALLERGY
    TYPE(74, 'SHELLFISH', '12-JUN-02', NULL), SIALLERGY_TYPE(68, 'PEANUTS', '13-J
    UN-02', NULL), SI_ALLERGY_TYPE(75, 'STRAWBERRIES', '13-JUN-02', NULL))
    SI_ALLERGY_TAB()
    75 STRAWBERRIES 13-JUN-02
    *******Notice the allergy entry of 75, Strawberries, 13-JUN-02 at the
    end. This is what I want not all the other exploded data.
    SQL> desc si_a31_per_vw
    Name Null? Type
    ........ Omitted uneeded previous column desc because of metalink
    character limit but the view is bigger then this.......
    DEPT_NAME VARCHAR2(20)
    DIV_NAME VARCHAR2(20)
    ADDRESSES SI_ADDRESS_TAB
    CURRENT_ALLERGIES SI_ALLERGY_TAB
    DELETED_ALLERGIES SI_ALLERGY_TAB
    SQL> desc si_allergy_tab
    si_allergy_tab TABLE OF SI_ALLERGY_TYPE
    Name Null? Type
    ALG_SEQ NUMBER
    ALG_NAME VARCHAR2(50)
    START_DATE DATE
    STOP_DATE DATE
    SQL> desc si_allergy_type
    Name Null? Type
    ALG_SEQ NUMBER
    ALG_NAME VARCHAR2(50)
    START_DATE DATE
    STOP_DATE DATE

    Can you explain what do you mean by the following?
    "PL/SQL tables (a.k.a. Index-by tables) cannot be used as the basis for columns and/or attributes"There are three kinds of collections:
    (NTB) Nested Tables
    (VAR) Varrying Arrays
    (IBT) Index-by Tables (the collection formerly known as "PL/SQL tables")
    NTB (and VAR) can be defined as persistent user defined data types, and can be used in table DDL (columns) and other user defined type specifications (attributes).
    SQL> CREATE TYPE my_ntb AS TABLE OF INTEGER;
    SQL> CREATE TABLE my_table ( id INTEGER PRIMARY KEY, ints my_ntb );
    SQL> CREATE TYPE my_object AS OBJECT ( id INTEGER, ints my_ntb );
    /IBT are declared inside stored procedures only and have slightly different syntax from NTB. Only variables in stored procedures can be based on IBT declarations.
    CREATE PROCEDURE my_proc IS
       TYPE my_ibt IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;  -- now you see why they are called Index-by Tables
       my_ibt_var my_ibt;
    BEGIN
       NULL;
    END;That sums up the significant differences as it relates to how they are declared and where they can be referenced.
    How are they the same?
    NTB and VAR can also be (non-persistently) declared in stored procedures like IBTs.
    Why would you then ever use IBTs?
    IBTs are significantly easier to work with, since you don't have to instantiate or extend them as you do with NTB and VAR, or
    Many other highly valuable PL/SQL programs make use of them, so you have to keep your code integrated/consistent.
    There's a lot more to be said, but I think this answers the question posed by Sri.
    Michael

  • Reg: Querying Nested table.

    Hi,
    I am facing a problem with querying the Nested table.
    I have created a type
    CREATE OR REPLACE TYPE TY_BOOKS OBJECT(           VC_BOOK_NAME VARCHAR2(64)          );
    CREATE OR REPLACE TYPE NT_TY_BOOKS AS TABLE OF TY_BOOKS;
    I have used this nested table in a table Student.
    CREATE TABLE STUDENT
    ( SID NUMBER(10),
    CL_NT_BOOKS NT_TY_BOOKS)
    NESTED TABLE CL_NT_BOOKS STORE AS CL_NT_BOOKS_TAB;
    The problem is one student can have more than one book. So if I need to select the students who have 'Science' books, i wrote this query.
    SELECT S.SID,B.VC_BOOK_NAME FROM STUDENT S, TABLE(CL_NT_BOOKS) B WHERE B.VC_BOOK_NAME='Science';
    suppose in the table
    SID BOOK_NAME
    1000          CL_NT_BOOKS('Science')
    1001          CL_NT_BOOKS('Maths'),CL_NT_BOOKS('Science')
    This query will return only those student-ids who have only "Science" book not those student-ids who have "Maths" & "Science" books.
    RESULT
    1000          Science
    but not 1001....
    Please can any one send me the select query which can select iteratively for books names which contains more than one value.

    Hmm, mysterious. It works for me on my 9.2.0.6 dB...
    SQL> CREATE OR REPLACE TYPE TY_BOOKS AS  OBJECT( VC_BOOK_NAME VARCHAR2(64) );
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE NT_TY_BOOKS AS TABLE OF TY_BOOKS;
      2  /
    Type created.
    SQL> CREATE TABLE STUDENT
      2  ( SID NUMBER(10),
      3  CL_NT_BOOKS NT_TY_BOOKS)
      4  NESTED TABLE CL_NT_BOOKS STORE AS CL_NT_BOOKS_TAB;
    Table created.
    SQL> INSERT INTO student VALUES (1000, NT_TY_BOOKS(TY_BOOKS('Science')))
      2  /
    1 row created.
    SQL> INSERT INTO student VALUES (1001, NT_TY_BOOKS(TY_BOOKS('Science'),TY_BOOKS('Maths')))
      2  /
    1 row created.
    SQL>
    SQL> SELECT S.SID,B.VC_BOOK_NAME FROM STUDENT S, TABLE(CL_NT_BOOKS) B
      2  WHERE B.VC_BOOK_NAME='Science'
      3  /
           SID VC_BOOK_NAME
          1000 Science
          1001 Science
    SQL> What I suggest is most likely to have happened is that you have added a space or some other non-printing cahracter into the book name when you inserted row 1001. If this is not the case then you'll have to do it again in SQL*Plus, cut teh output and paste it here, so we can see what's going on.
    Cheers, APC

Maybe you are looking for