Query small set of record in a big table.

Hi,
in 11.2.0.2 i've a table with about 2milions of record.
I use a query that like:
select *
FROM DOC
WHERE INDENTIF = 1001 AND TRASF = 0;
to identify new record in the table (TRASF=0).
INDENTIF column contains 5 distinct key and TRASF can be 0,1,2
SELECT COUNT (*), INDENTIF , TRASF
FROM DOC
BY INDENTIF, TRASF
COUNT     IDENTIF     TRASF
9           1004          2
1359        1005          1
1           1001          2
306859      1004          1
767090      1002         1
2           1002         2
782981      1001         1
There is an index on INDENTIF , TRASF but oracle uses full scan.
Stats are available.
Every time i check for new record it perform a full scan also
if there aren't new record.
Is there a method to use an index without use hint?
Thank you

MartinPreiss ha scritto:
seeing the results from dba_tab_cols_statistics I think it could be a problem with TRASF and the sample_size: there are two known values (I assume 1 and 2) but only one bucket. For a value not included into the histogram the calculation of selectivity may bring very high results since 10.2.0.4: http://jonathanlewis.wordpress.com/2009/04/23/histogram-change/: "If the value you supply does not appear in the histogram, but is inside the low/high range of the histogram then the cardinality will be half the cardinality of the least frequently occurring value that is in the histogram." For a value outside the known range the result will be smaller, but may still be much too high. Perhaps you can give as the plans for:
select *
FROM DOC
WHERE TRASF = 0;
select *
FROM DOC
WHERE TRASF = 1;
select *
FROM DOC
WHERE TRASF = 2;
SQL> set autotrace traceonly explain
SQL> select *
FROM DOC
WHERE TRANSF = 0;  2    3
Execution Plan
Plan hash value: 3984526059
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |      |   929K|    18M|  2137   (2)| 00:00:26 |
|*  1 |  TABLE ACCESS FULL|  DOC |   929K|    18M|  2137   (2)| 00:00:26 |
Predicate Information (identified by operation id):
   1 - filter("TRANSF"=0)
SQL> select *
FROM DOC
WHERE TRANSF = 1;  2    3
Execution Plan
Plan hash value: 3984526059
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |      |  1858K|    37M|  2142   (2)| 00:00:26 |
|*  1 |  TABLE ACCESS FULL|  DOC |  1858K|    37M|  2142   (2)| 00:00:26 |
Predicate Information (identified by operation id):
   1 - filter("TRANSF"=1)
SQL> select *
FROM DOC
WHERE TRANSF = 2;  2    3
Execution Plan
Plan hash value: 3984526059
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |      |   929K|    18M|  2137   (2)| 00:00:26 |
|*  1 |  TABLE ACCESS FULL|  DOC |   929K|    18M|  2137   (2)| 00:00:26 |
Predicate Information (identified by operation id):
   1 - filter("TRANSF"=2)

Similar Messages

  • Query to display all records count of all tables in a schema

    Hi,
    I need to count all the records of all my tables in a certain schema and display the max amount of the record count. Do you have a script for this one??

    SQL> create function countrec(in_tab in varchar2) return number is
      2  retval number;
      3  begin
      4    execute immediate 'select count(*) from '||in_tab into retval;
      5    return retval;
      6  end;
      7  /
    Function created.
    SQL> select table_name, countrec(table_name)
      2  from tabs;
    TABLE_NAME                     COUNTREC(TABLE_NAME)
    QUERY_TOOL_DATA_COLLECTION                        5
    TEST01                                            0
    T1                                               14
    EMP                                              14
    SALGRADE                                          5
    FILES                                             0
    PROVA                                             0
    TEST                                              0
    T_MASTER                                          1
    T_CHILD                                           3
    TAB_ONE                                          30
    TAB_TWO                                          10
    A                                                 3
    B                                                 4
    C                                                 3
    D                                                 3
    BONUS                                             0
    DEPT                                              4
    18 rows selected.Max

  • Set the records in ALV output table

    Dear Experts,
    How to set the number of records in the ALV output as 10..i.e .. When user executes WD application the output
    of the ALV output table should contains only 10 records in every page.
    Thanks in advance.

    Hi Venkat
    Use the method SET_VISIBLE_ROW_COUNT of interface IF_SALV_WD_TABLE_SETTINGS.
    the following code may help you.
    DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
      DATA : lr_table_settings TYPE REF TO if_salv_wd_table_settings.
      l_ref_cmp_usage =   wd_This->wd_CpUse_Appr( ).
      if l_ref_cmp_usage->has_active_component( ) is initial.
        l_ref_cmp_usage->create_component( ).
      endif.
      l_ref_INTERFACECONTROLLER =   wd_This->wd_CpIfc_Appr( ).
      data:
        l_VALUE type ref to Cl_Salv_Wd_Config_Table.
      l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model(
    lr_table_settings = l_value.
    lr_table_settings->set_visible_row_count( 10).
    Regards
    Naresh
    Edited by: Naresh Kumar Malik on Jun 20, 2008 11:46 AM

  • Deleting records from Self-Referencing Table

    I am using this query to dodge the foreign key error when trying to delete a record from a table that has primary key and referencing foreign key in the same table. It works with smaller set of data but for a table with 400,000 records it fails with error
    : maximum recursion limit of 500 reached. I changed maxrecursion to 3267 and even 0. but no records were returned it infact went to infinite loop..
    Please help if u have an alternative solution othr than a cascade trigger(which I am already considering)
    WITH    q AS
            SELECT  id, siteUrl
            FROM    TestComposite
            WHERE   id = 42
                    AND siteUrl = 'site1'
            UNION ALL
            SELECT  tc.id, tc.siteUrl
            FROM    q
            JOIN    TestComposite tc
            ON      tc.parentID = q.id
                    AND tc.siteUrl = q.siteUrl
    select * 
    FROM    TestComposite
    WHERE   EXISTS
            SELECT  id, siteUrl
            INTERSECT
            SELECT  id, siteUrl
            FROM    q
    Thanks,
    J

    I am using this query to dodge the foreign key error when trying to delete a record from a table that has primary key and referencing foreign key in the same table. It works with smaller set of data but for a table with 400,000 records it fails with error
    : maximum recursion limit of 500 reached. I changed maxrecursion to 3267 and even 0. but no records were returned it in fact went to infinite loop..
    That is a questionable approach. Don't dodge table constraints. They have a reason to be there. Deep recursion is also doubtful approach.
    USE tempdb;
    GO
    SELECT * INTO Employee FROM AdventureWorks.HumanResources.Employee;
    GO
    ALTER TABLE Employee ADD constraint PK PRIMARY KEY (EmployeeID);
    ALTER TABLE Employee ADD constraint fkPK FOREIGN KEY (ManagerID) REFERENCES Employee(EmployeeID);
    GO
    SELECT * FROM Employee;
    GO
    -- Staff - no child records
    DELETE Employee WHERE EmployeeID = 283; -- (1 row(s) affected)
    -- Manager - child records
    DELETE Employee WHERE EmployeeID = 284;
    Msg 547, Level 16, State 0, Line 19
    The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "fkPK". The conflict occurred in database "tempdb", table "dbo.Employee", column 'ManagerID'.
    The statement has been terminated.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • SELECT query performance : One big table Vs many small tables

    Hello,
    We are using BDB 11g with SQLITE support. I have a query about 'select' query performance when we have one huge table vs. multiple small tables.
    Basically in our application, we need to run select query multiple times and today we have one huge table. Do you guys think breaking them into
    multiple small tables will help ?
    For test purposes we tried creating multiple tables but performance of 'select' query was more or less same. Would that be because all tables will map to only one database in backed with key/value pair and when we run lookup (select query) on small table or big table it wont make difference ?
    Thanks.

    Hello,
    There is some information on this topic in the FAQ at:
    http://www.oracle.com/technology/products/berkeley-db/faq/db_faq.html#9-63
    If this does not address your question, please just let me know.
    Thanks,
    Sandra

  • Oracle query returns every expected record twice

    I have a query that at times could return a very large number of records, but I want to process them in blocks within a time budget, so I will process as many as I can within a time budget and then close the ResultSet. I looked at the two obvious ways to control how many rows I get back, using "ROWNUM <= N" and "setFetchSize()".
    I think the latter is the more common way of doing this, but I noticed that it's considered a "hint". I think it's likely it would always be used, but because of that small doubt I decided to try using the "ROWNUM <= N" strategy first.
    It seemed to be working fine, but I noticed an oddity where it was often returning all the relevant rows twice. I'd gotten the set of records to operate on down to a very small number (8), and I entered the query it uses directly into a SQL browser, and it returned the 8 records I expected. My query was using "ROWNUM <= 20". I stepped into the ResultSet "next()" loop, and I watched it process the 8 records, and then instead of returning "false" from the following call to "rs.next()", it returned true and started at the beginning of the 8 records again. It eventually processed all 8 records twice.
    So, I just tried changing it from using "ROWNUM" to using "setFetchSize()". The results were exactly the same. It still processed all 8 records twice.
    The query is very simple. It just looks like this, with most of the column names removed, and the table name changed:
    SELECT ID, ... FROM TABLE_NAME tn WHERE tn.CREATION_DATE = ?
    The somewhat elided code for the loop looks like this:
    try {
    rs = getRecords(connection);
    // Indicates whether at least one row was found.
    boolean foundOne = false;
    while (rs.next()) {
    foundOne = true;
    final Record record = makeRecord(rs);
    processRecord(record, counters);
    ++ recordsProcessed;
    if (!foundOne) {
    break;
    if (overTimeBudget(startTime)) {
    break;
    logInfo("Processed " + recordsProcessed + " record" +
    (recordsProcessed == 1 ? "" : "s") + " so far.");
    What could be going wrong here?

    Never mind. Dumb mistake. It wasn't an Oracle problem. I was doing the query inside a loop because of an earlier design decision.

  • How to devide the set of records into groups in SQL itself.

    Hi , i am using 10.2.4.0 of oracle.
    I am having one requirement, in which i have to devide the set of records into certain groups , so that they can be executed partly but not in one run.
    So in the 'SELECT' clause itself i want to asssign particular value (may be 1 )to first 50000 records then another value(may be 2) to next 10000, like wise. And again the total count of records will also varry time to time , if the total count of record set is less than 10000 , then it should only assign '1' to all the records. i will set the group values (1,2,3...) as another column itself.
    Can you please let me know if this can be done in SQL without going for PLSQL?

    Hi,
    That's called a Pagination Query , and here's one way to do it:
    WITH     got_grp          AS
         SELECT     x.*
         ,     CEIL ( ROW_NUMBER () OVER (ORDER BY  x_id) 
                   / 50000
                   )          AS grp
         FROM     table_x  x
    --     WHERE     ...          -- If you need any filtering, put it here
    SELECT     *               -- Or list the columns you want
    FROM     got_grp
    WHERE     grp     = 1
    ;ROW_NUMBER () OVER (ORDER BY x_id)     assigns unique integers 1, 2, 3, ... to all all rows, in the same order as x_id (even if x_id is not unique).
    CEIL (ROW_NUMBER () OVER (ORDER BY x_id) / 50000)     maps the 1st 50,000 of those numbers to 1, the 2nd 50,000 to 2, and so on.
    Analytic functions (like ROW_NUMBER) as computed after the WHERE clause is applied, so, to use the results in a WHERE clause, then you need to compute them in a sub-query. If you just want to display the number, and not use it in a WHERE clause, then you don't need a sub-query.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • How does jdbc fetch a set of records in oracle

    Hi,
    Oracle does not support server side cursors,if so how does jdbc fetch a set of records(set by setFetchSize(), which is 10 by default) each time I say rs.next().Does this mean Query is re-executed to fetch the next set of records? Can some body throw some light on this?
    thanx in advance
    Gnayan

    You are asking about implementation details of some JDBC driver, but you don't say which one. This makes it very difficult to answer your question. You might want to try asking the question of the people who wrote the driver.

  • Problem w/ geting a unique set of records. Too many rows returned

    This is a query that is looking at itself for two diff reasons.
    The d pass is to search the records that are not voided and pass lmc is the records that are the voids.
    I have to identify the valid recs to be voided and then mark them accordingly but I am getting repeating values
    SELECT DISTINCT
    d.CHARGE_ID,
    lmc.CHARGE_ID as CHARGE_ID_THAT_VOIDED_ME ,
    ROW_NUMBER() OVER (PARTITION BY d.charge_id ORDER BY LMC.SOURCE_SYSTEM_RECORD_ID DESC ) AS rown
    FROM CHARGES d
    INNER JOIN CHARGES lmc
    ON d.Encounter_id = LMC.ENCOUNTER_ID
    WHERE d.TRANSACTION_TYPE_CODE = 0 --not voided
    AND lmc.transaction_type_code = 1 --void records that have limited values to tell me what to void
    AND d.SOURCE_SYSTEM = 'MM' --this is my source system
    AND ( d.IMPUTED_SB_MAP + lmc.IMPUTED_SB_MAP) = 0 --sadly one of those values is the dollar amt. Problem occurs when there are two voids of the same value
    CHARGE_ID CHARGE_ID_THAT_VOIDED_ME ROWN
    10138466 10138459 1
    10138467 10138460 1
    10138468 10138462 1
    10138468 10138461 2
    10138469 10138462 1
    10138469 10138461 2
    10138470 10138463 1
    As you can see I will not get a proper set of values to record the Charge Id that voided me for the charge Id to be voided.
    I am having a real issue with this one.
    Please help

    So many looked and were not able to help.By all mean I hold nothing against anyone. Thankfully I never give up and this is what we did:
    1. A table called CHARGES_N_VOID_STG was created
    2. in the declaration section of my procedure:
    cursor c_voids is select * from CHARGES_N_VOIDS_STG;
    Then after the BEGIN:
              If there were any voids in these clean charges, then you must set the valid
              record that it is offsetting to a transaction type code of 2
    EXECUTE IMMEDIATE 'TRUNCATE table CHARGES_N_VOIDS_STG';
    --Insert the voids that have not been processed.
    --If the CHARGE_ID_I_VOIDED is null then it has not been processed                
    INSERT INTO CHARGES_N_VOIDS_STG
    (     CHARGE_ID_Void,
    IMPUTED_SB_MAP_Void,
    BATCH_ID_Void,
    RECORD_SEQ_Void,
    ENCOUNTER_ID_Void,
    SERVICE_CODE_VOID)
    SELECT     DISTINCT
    v.CHARGE_ID,
    v.IMPUTED_SB_MAP,
    v.BATCH_ID,
    v.RECORD_SEQ,
    v.ENCOUNTER_ID,
    V.SERVICE_CODE
    FROM      CHARGES v
    WHERE     v.TRANSACTION_TYPE_CODE = 1
    AND          v.SOURCE_SYSTEM = 'MM'
    AND           v.CHARGE_ID_I_VOIDED IS NULL;
    --For each void record in the temp table..
    FOR r_void IN c_voids LOOP
    --Update the stage table records with a valid charge to be voided          
    UPDATE      CHARGES_N_VOIDS_STG
    SET          CHARGE_ID_Valid =
    (     SELECT      MAX(CHARGE_ID) AS CHARGE_ID
    FROM          CHARGESDS.CHARGES
    WHERE     ENCOUNTER_ID = r_void.ENCOUNTER_ID_Void
    AND          CHARGE_ID_THAT_VOIDED_ME IS NULL
    AND          (IMPUTED_SB_MAP + r_void.IMPUTED_SB_MAP_Void) = 0
    AND          SERVICE_CODE = r_void.SERVICE_CODE_VOID)
    WHERE     BATCH_ID_VOID = r_void.BATCH_ID_Void
    AND          RECORD_SEQ_VOID = r_void.RECORD_SEQ_Void     
    AND           ENCOUNTER_ID_Void IN
    (     SELECT      ENCOUNTER_ID
    FROM          CHARGESDS.CHARGES
    WHERE     ENCOUNTER_ID = r_void.ENCOUNTER_ID_Void
    AND          CHARGE_ID_THAT_VOIDED_ME IS NULL
    AND          (IMPUTED_SB_MAP + r_void.IMPUTED_SB_MAP_Void) = 0);
    --Update a charge with the record's charge ID that voided it and change the trans type code
    -- to 2 and last mod and last modify process id
    UPDATE      CHARGES
    SET          CHARGE_ID_THAT_VOIDED_ME = r_void.CHARGE_ID_VOID,
    TRANSACTION_TYPE_CODE = '2',
    LAST_MODIFIED = sysdate,
    LAST_MODIFY_PROCESS_ID = pCHGDS_PROCESS_ID
    WHERE      CHARGE_ID IN
    (     SELECT      MAX(CHARGE_ID) AS CHARGE_ID
    FROM          CHARGESDS.CHARGES
    WHERE     ENCOUNTER_ID = r_void.ENCOUNTER_ID_Void
    AND          CHARGE_ID_THAT_VOIDED_ME IS NULL
    AND          (IMPUTED_SB_MAP + r_void.IMPUTED_SB_MAP_Void) = 0
    AND          SERVICE_CODE = r_void.SERVICE_CODE_VOID);
    END LOOP; ----For each void in the temp table..
    --Update the voids in Charges with a value that indicates the void has been processed
    UPDATE      CHARGES
    SET          CHARGE_ID_I_VOIDED = (
    SELECT     CHARGE_ID_Valid
    FROM          CHARGES_N_VOIDS_STG
    WHERE     CHARGES.CHARGE_ID = CHARGE_ID_Void)
    WHERE     EXISTS (
    SELECT     CHARGE_ID_Valid
    FROM          CHARGES_N_VOIDS_STG
    WHERE     CHARGES.CHARGE_ID = CHARGE_ID_Void);
    We had no choice but to find the voids first then go through each and find only one records to void that matched our criteria. Some of you may have thought that the client should have put more data to make it easier to find each record but some clients are what they are and you have to make the best of it.
    Thanks and You are welcome
    NAMASTE

  • Execute query. Not all records retrieved.

    Hi everyone.
    I have made a screen with the data block and layout wizzards.
    When I click on the default toolbar "Execute query" it brings only 68 records and there are about 25,000!.
    I have a botton which displays a LOV of the same table and the LOV is working well, it brings all the records in the table.
    Any idea ???
    Thanks!

    If you go to the bottom of the query, does
    it get the next set of records??
    Oracle forms buffers the records it gets
    based upon the number of records buffered
    in the "block properties".
    Go to block properties. Look at Number of
    records buffered. If you want it to get
    ALL records. Set the Query ALL records switch
    to "Yes". Try it again.
    Hopefully this helps.

  • Limit on Query result set

    Limit on Query result set
    Is there anyway in Oracle9i to limit query result
    I.e.: we can limit query result in MySQL
    SELECT * FROM EMP LIMIT 2;
    Will return only top 2 records
    Thanks in advance

    SELECT * FROM EMP WHERE ROWNUM <= 2;

  • Pass a set of Records form Form to a Report

    Hi,
    Lets say that I've already fetched a set of records on Oracle Form, and I want to pass these reocrds to a Report " on the Report I dont wana use range or where clause to give me these recods"
    Any ideas how to do that please?
    Thanks!

    Passing a (Forms) Record Group as DATA_PARAMETER to Reports:
    First example:
    Forms code (in WHEN-BUTTON-PRESSED trigger) calls reports module
    and sends record group "rg_dept" (populated from :SYSTEM.LAST_QUERY) as parameter:
    DECLARE
    rg_id_l RECORDGROUP;
    rg_name_l VARCHAR2 (30) := 'RG_DEPT';
    status_l NUMBER;
    pl_id_l PARAMLIST;
    pl_name_l VARCHAR2 (30) := 'PARAM_LIST';
    BEGIN
    rg_id_l := FIND_GROUP (rg_name_l);
    IF NOT ID_NULL (rg_id_l) THEN
    DELETE_GROUP (rg_id_l);
    END IF;
    rg_id_l := CREATE_GROUP_FROM_QUERY (rg_name_l, :SYSTEM.LAST_QUERY);
    status_l := POPULATE_GROUP (rg_id_l);
    IF status_l <> 0 THEN
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    pl_id_l := GET_PARAMETER_LIST (pl_name_l);
    IF NOT ID_NULL (pl_id_l) THEN
    DESTROY_PARAMETER_LIST (pl_id_l);
    END IF;
    pl_id_l := CREATE_PARAMETER_LIST (pl_name_l);
    ADD_PARAMETER (pl_id_l, 'Q_1', DATA_PARAMETER, rg_name_l);
    RUN_PRODUCT (REPORTS, 'rec_group', SYNCHRONOUS, RUNTIME, FILESYSTEM, pl_id_l, NULL);
    END;
    Reports module must have query with the same name as parameter in ADD_PARAMETER
    statement (in this code - "Q_1"), and SQL Query Statement in Reports must have
    same number and type of columns as record group, for example:
    SELECT ROWID, 1 deptno, 'x' dname, 'x' loc FROM DUAL
    And - we can't pass a DATA_PARAMETER to a child query in Report Builder.
    Data passing is supported only for master queries.
    Second example:
    Forms transfers to Reports records from "dept" block,
    using non-query record group (populated from Forms "dept" block in a LOOP):
    DECLARE
    rg_id_l RECORDGROUP;
    rg_name_l VARCHAR2 (30) := 'DEPT';
    row_count_l NUMBER;
    rgc_id_l GROUPCOLUMN;
    pl_id_l PARAMLIST;
    pl_name_l VARCHAR2 (30) := 'PARAM_LIST';
    BEGIN
    rg_id_l := FIND_GROUP (rg_name_l);
    IF NOT ID_NULL (rg_id_l) THEN
    DELETE_GROUP (rg_id_l);
    END IF;
    rg_id_l := CREATE_GROUP (rg_name_l);
    rgc_id_l := ADD_GROUP_COLUMN (rg_id_l, 'deptno', NUMBER_COLUMN);
    rgc_id_l := ADD_GROUP_COLUMN (rg_id_l, 'dname', CHAR_COLUMN, 14);
    rgc_id_l := ADD_GROUP_COLUMN (rg_id_l, 'loc', CHAR_COLUMN, 13);
    GO_BLOCK ('dept');
    FIRST_RECORD;
    row_count_l := 0;
    LOOP
    row_count_l := row_count_l + 1;
    ADD_GROUP_ROW (rg_id_l, row_count_l);
    SET_GROUP_NUMBER_CELL (rg_name_l || '.deptno', row_count_l, :dept.deptno);
    SET_GROUP_CHAR_CELL (rg_name_l || '.dname', row_count_l, :dept.dname);
    SET_GROUP_CHAR_CELL (rg_name_l || '.loc', row_count_l, :dept.loc);
    EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
    NEXT_RECORD;
    END LOOP;
    IF row_count_l = 0 THEN
    MESSAGE ('Nothing to print'); PAUSE;
    RETURN;
    END IF;
    pl_id_l := GET_PARAMETER_LIST (pl_name_l);
    IF NOT ID_NULL (pl_id_l) THEN
    DESTROY_PARAMETER_LIST (pl_id_l);
    END IF;
    pl_id_l := CREATE_PARAMETER_LIST (pl_name_l);
    ADD_PARAMETER (pl_id_l, 'Q_1', DATA_PARAMETER, rg_name_l);
    RUN_PRODUCT (REPORTS, 'REC_GROUP_REPORT', SYNCHRONOUS, RUNTIME, FILESYSTEM, pl_id_l, NULL);
    END;
    This works in Forms 6i. In Forms 9i we must use RUN_REPORT_OBJECT instead of RUN_PRODUCT
    (see Oracle MetaLink document 110495.1 "Passing a Record Group to Reports Using RUN_REPORT_OBJECT").
    Regards,
    Zlatko Sirotic

  • Efficiently retrieving only a set of records ... ?

    Hi,
    Ours is web centric small-scale ERP. We have lot of reports which display data by pages.
    While retrieving records we are using the following type of SQLs:
    select col1,col2,.... from (
    select rownum srno, col1, col2, ... from tables where ...)
    where srno between 1 and 100;
    (100 records per page)
    But we know that the sub-query is going to do a full table scan and then the main query will filter the records based on the 'srno' column.
    Does anybody know any better way of retrieving records without a having the sub-query do a full table scan?
    I would really appreciate your response.
    TIA.

    If you are on Oracle9i, you could use the PL/SQL package DBMS_XMLQUERY to get XML output (optionally you could also
    apply an XSLT stylesheet right inside the database to convert it into an HTML). This package has two procedures
    setMaxRows => Maximum number of rows to return for your query
    setSkipRows => Rows to skip before query results are returned
    using this combination, you could call a PL/SQL package with different starting point this package will get you the
    rows starting from that row (in XML format or optionally in HTML after applying XSLT).
    Once you have the output, you could pass it to the front end and if needed, apply the stylesheet binding there to display
    to the client.
    You can also take advantage of using bind variables to query for different data values.

  • How to fetch 2 set of records in MII from SQL procedure

    Hi Experts,
    I am invoking a SQL procedure from MII which return 2 set of records. But at MII I am able to get only first set of records. Is there any configuration required at MII side or SQL side to get both set of records in MII?
    Here is the SQL Query Structure
    Create procedure Sample_Proc
      @Param1 Varchar(10),
      @Param2 varchar(10),
      @Param3 Varchar(20) OUT,
      SET INCOUNT ON;
    AS
    Begin
      *//Selection statements//*
    END
    SP Executing in MII
    Declare @Param1,
      @Param2,
      @Param3,
    Exec Sample_Proc
      @Param1='name',
      @Param2='Id',
      @Param3=@Param3 OUTPUT,
    Select @Param3
    Our SP is returning values (Say Recordset1)based on the input parameters 1 and 2 , along with Parameter3 value(Say Recordset2) in MS SQL server but in MII its returning only the values(Recordset1) ... how to fetch recordset2 values in MII
    I hope MII can return 2 set of records (rowsets) after executing the procedure.
    MII version -> 12.2.3 Build(182)
    Thanks & Regards,
    Rajasekhar Kantepalli

    Hi Swaroop,
    With MII 14.0 SP5 Patch 11, in a transaction, I get following XML output for a query that executes an SP(returning multiple resultSets) :
    And, results in this format can surely be used for further processing in an MII transaction.
    Thanks Rajasekhar, got to know about this because of your query.
    regards,
    Manisha

  • How to select a row from duplicate set of records?

    I want to select a row from a duplicate set of records.
    below is the explanation of my requirement.
    select * from test_dup;
    COL_BILL     COL_SERV     COL_SYS
    b1     s1     c
    b1     s1     g
    b1     s2     c
    b1     s2     g
    b2     s2     g
    b2     s3     c
    b2     s3     g
    b3     s3     c
    Here what I want is, for a distinct col_sys if col_bill and col_serv is same then I need the row where col_sys='c'
    from the above result set I need the following:
    b1     s1     c
    b1     s2     c
    b2     s3     c
    I am using the following SQL query which is giving me the correct result set. But it will hamper the performance because there are total 45 columns in the table and total volume is around 50 million.
    select * from test_dup where col_bill||col_serv in (
    select col_bill||col_serv from (
    select col_bill,col_serv,count(*) from test_dup
    where col_sys in ('c','g')
    group by col_bill,col_serv having count(*) >1)) and
    col_sys='c';
    Can anyone please provide me the optimize SQL query for the same.

    Hi,
    Another way,
    SQL> with test_dup
    as
         select 'b1' col_bill, 's1' col_serv, 'c' col_sys from dual union all
         select 'b1', 's1', 'g' from dual union all
         select 'b1', 's2', 'c' from dual union all
         select 'b1', 's2', 'g' from dual union all
         select 'b2', 's2', 'g' from dual union all
         select 'b2', 's3', 'c' from dual union all
         select 'b2', 's3', 'g' from dual union all
         select 'b3', 's3', 'c' from dual
      select col_bill, col_serv, min(col_sys) col_sys
        from test_dup
       where col_sys in ('c', 'g')
    group by col_bill, col_serv
      having count( * ) > 1
         and count(nullif(col_sys, 'g')) > 0;
    CO CO C
    b1 s1 c
    b2 s3 c
    b1 s2 c
    3 rows selected.Regards
    Peter
    Edited by: Peter on Feb 18, 2009 1:10 AM
    - Added test data, thanks Karthick

Maybe you are looking for

  • Is that possible to display the user selection data in the printable page?

    Hi All, I'm going to add a printablepage button on my page. Here comes a questions. Is that possible to display the user selection data in the printable page? For example, I have a table in the page,with 10 records.User select 5 of them.Can I display

  • Ghost thumbnails and No files on HD

    My iphoto images are suddenly appearing as blank gray ghosts. All the photo data appears to remain saved for each image, but the visual image itself is missing, with only a gray ghost image left behind. Neither the thumbnails nor the full size jpg sh

  • Retrieve fieldtext with dynamic table.

    Hy everyone , Is it possible to retrieve the long or medium text of a field label in data element using cl_abap_elemdescr or cl_abap_typedescr ? Thank's a lot. !!

  • Multiple Network Instances?

    Hey everyone, I've got a design question for you guys. I have an program that could potentially be run from multiple workstations on a network. When this program starts, it needs to know if there are any other instances of itself already running some

  • Error when new entering in combolist

    hi all, when i search in combolist using (post-change trigger) its work correctly first time. but when i delete the letters for new input the error frm-40735 raised. i made the combolist a non-database item. and the list has two triggers (1) post-cha