OVD 11.1.1.7 pagination query

Hi All,
I'm working on OVD 11.1.1.7 implementation for a customer. I've used LSA adapter to provide unified view of two AD adapters underneath. The requirement is to authenticate client specific applications against OVD for login/logout purposes. They also have pagination feature to be implemented. I've seen Proxy Paging size in AD adapter configurations and I've set it to 10k and it is fine until this value. When we increase this value to 25k, we are getting size limit reached errors.
How do we actually increase this value to support client SLAs? Can you please give your thoughts?
Thanks
mahendra.

See your duplicate post here - 11.1.0.6 to 11.1.0.7
For Win 2003, 11.1.0.7 is a patch that needs to be downloaded from My Oracle Support. You install it on top of a 11.1.0.6 install.
Access to My Oracle Support requires a valid Customer Support Identifier, which is given when you purchase support from Oracle.
HTH
Srini

Similar Messages

  • Pagination query help needed for large table - force a different index

    I'm using a slight modification of the pagination query from over at Ask Tom's: [http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html]
    Mine looks like this when fetching the first 100 rows of all members with last name Smith, ordered by join date:
    SELECT members.*
    FROM members,
        SELECT RID, rownum rnum
        FROM
            SELECT rowid as RID
            FROM members
            WHERE last_name = 'Smith'
            ORDER BY joindate
        WHERE rownum <= 100
    WHERE rnum >= 1
             and RID = members.rowidThe difference between this and the one at Ask Tom's is that my innermost query just returns the ROWID. Then in the outermost query we join the ROWIDs returned to the members table, after we have pruned the ROWIDs down to only the chunk of 100 we want. This makes it MUCH faster (verifiably) on our large tables, as it is able to use the index on the innermost query (well... read on).
    The problem I have is this:
    SELECT rowid as RID
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindateThis will use the index for the predicate column (last_name) instead of the unique index I have defined for the joindate column (joindate, sequence). (Verifiable with explain plan). It is much slower this way on a large table. So I can hint it using either of the following methods:
    SELECT /*+ index(members, joindate_idx) */ rowid as RID
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindate
    SELECT /*+ first_rows(100) */ rowid as RID
    FROM members
    WHERE last_name = 'Smith'
    ORDER BY joindateEither way, it now uses the index of the ORDER BY column (joindate_idx), so now it is much faster as it does not have to do a sort (remember, VERY large table, millions of records). So that seems good. But now, on my outermost query, I join the rowid with the meaningful columns of data from the members table, as commented below:
    SELECT members.*      -- Select all data from members table
    FROM members,           -- members table added to FROM clause
        SELECT RID, rownum rnum
        FROM
            SELECT /*+ index(members, joindate_idx) */ rowid as RID   -- Hint is ignored now that I am joining in the outer query
            FROM members
            WHERE last_name = 'Smith'
            ORDER BY joindate
        WHERE rownum <= 100
    WHERE rnum >= 1
            and RID = members.rowid           -- Merge the members table on the rowid we pulled from the inner queriesOnce I do this join, it goes back to using the predicate index (last_name) and has to perform the sort once it finds all matching values (which can be a lot in this table, there is high cardinality on some columns).
    So my question is, in the full query above, is there any way I can get it to use the ORDER BY column for indexing to prevent it from having to do a sort? The join is what causes it to revert back to using the predicate index, even with hints. Remove the join and just return the ROWIDs for those 100 records and it flies, even on 10 million records.
    It'd be great if there was some generic hint that could accomplish this, such that if we change the table/columns/indexes, we don't need to change the hint (the FIRST_ROWS hint is a good example of this, while the INDEX hint is the opposite), but any help would be appreciated. I can provide explain plans for any of the above if needed.
    Thanks!

    Lakmal Rajapakse wrote:
    OK here is an example to illustrate the advantage:
    SQL> set autot traceonly
    SQL> select * from (
    2  select a.*, rownum x  from
    3  (
    4  select a.* from aoswf.events a
    5  order by EVENT_DATETIME
    6  ) a
    7  where rownum <= 1200
    8  )
    9  where x >= 1100
    10  /
    101 rows selected.
    Execution Plan
    Plan hash value: 3711662397
    | Id  | Operation                      | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |            |  1200 |   521K|   192   (0)| 00:00:03 |
    |*  1 |  VIEW                          |            |  1200 |   521K|   192   (0)| 00:00:03 |
    |*  2 |   COUNT STOPKEY                |            |       |       |            |          |
    |   3 |    VIEW                        |            |  1200 |   506K|   192   (0)| 00:00:03 |
    |   4 |     TABLE ACCESS BY INDEX ROWID| EVENTS     |   253M|    34G|   192   (0)| 00:00:03 |
    |   5 |      INDEX FULL SCAN           | EVEN_IDX02 |  1200 |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("X">=1100)
    2 - filter(ROWNUM<=1200)
    Statistics
    0  recursive calls
    0  db block gets
    443  consistent gets
    0  physical reads
    0  redo size
    25203  bytes sent via SQL*Net to client
    281  bytes received via SQL*Net from client
    8  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
    101  rows processed
    SQL>
    SQL>
    SQL> select * from aoswf.events a, (
    2  select rid, rownum x  from
    3  (
    4  select rowid rid from aoswf.events a
    5  order by EVENT_DATETIME
    6  ) a
    7  where rownum <= 1200
    8  ) b
    9  where x >= 1100
    10  and a.rowid = rid
    11  /
    101 rows selected.
    Execution Plan
    Plan hash value: 2308864810
    | Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |            |  1200 |   201K|   261K  (1)| 00:52:21 |
    |   1 |  NESTED LOOPS               |            |  1200 |   201K|   261K  (1)| 00:52:21 |
    |*  2 |   VIEW                      |            |  1200 | 30000 |   260K  (1)| 00:52:06 |
    |*  3 |    COUNT STOPKEY            |            |       |       |            |          |
    |   4 |     VIEW                    |            |   253M|  2895M|   260K  (1)| 00:52:06 |
    |   5 |      INDEX FULL SCAN        | EVEN_IDX02 |   253M|  4826M|   260K  (1)| 00:52:06 |
    |   6 |   TABLE ACCESS BY USER ROWID| EVENTS     |     1 |   147 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("X">=1100)
    3 - filter(ROWNUM<=1200)
    Statistics
    8  recursive calls
    0  db block gets
    117  consistent gets
    0  physical reads
    0  redo size
    27539  bytes sent via SQL*Net to client
    281  bytes received via SQL*Net from client
    8  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
    101  rows processed
    Lakmal (and OP),
    Not sure what advantage you are trying to show here. But considering that we are talking about pagination query here and order of records is important, your 2 queries will not always generate output in same order. Here is the test case:
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      10.2.0.1
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    SQL> show parameter pga
    NAME                                 TYPE        VALUE
    pga_aggregate_target                 big integer 103M
    SQL> create table t nologging as select * from all_objects where 1 = 2 ;
    Table created.
    SQL> create index t_idx on t(last_ddl_time) nologging ;
    Index created.
    SQL> insert /*+ APPEND */ into t (owner, object_name, object_id, created, last_ddl_time) select owner, object_name, object_id, created, sysdate - dbms_random.value(1, 100) from all_objects order by dbms_random.random;
    40617 rows created.
    SQL> commit ;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(user, 'T', cascade=>true);
    PL/SQL procedure successfully completed.
    SQL> select object_id, object_name, created from t, (select rid, rownum rn from (select rowid rid from t order by created desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
    OBJECT_ID OBJECT_NAME                    CREATED
         47686 ALL$OLAP2_JOIN_KEY_COLUMN_USES 28-JUL-2009 08:08:39
         47672 ALL$OLAP2_CUBE_DIM_USES        28-JUL-2009 08:08:39
         47681 ALL$OLAP2_CUBE_MEASURE_MAPS    28-JUL-2009 08:08:39
         47682 ALL$OLAP2_FACT_LEVEL_USES      28-JUL-2009 08:08:39
         47685 ALL$OLAP2_AGGREGATION_USES     28-JUL-2009 08:08:39
         47692 ALL$OLAP2_CATALOGS             28-JUL-2009 08:08:39
         47665 ALL$OLAPMR_FACTTBLKEYMAPS      28-JUL-2009 08:08:39
         47688 ALL$OLAP2_DIM_LEVEL_ATTR_MAPS  28-JUL-2009 08:08:39
         47689 ALL$OLAP2_DIM_LEVELS_KEYMAPS   28-JUL-2009 08:08:39
         47669 ALL$OLAP9I2_HIER_DIMENSIONS    28-JUL-2009 08:08:39
         47666 ALL$OLAP9I1_HIER_DIMENSIONS    28-JUL-2009 08:08:39
    11 rows selected.
    SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
    OBJECT_ID OBJECT_NAME                    LAST_DDL_TIME
         11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
         13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
         37534 com/sun/mail/smtp/SMTPMessage  06-FEB-2010 03:46:14
         36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
         26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
         16695 /2940a364_RepIdDelegator_1_3   06-FEB-2010 03:38:17
         36539 sun/io/ByteToCharMacHebrew     06-FEB-2010 03:28:57
         14044 /d29b81e1_OldHeaders           06-FEB-2010 03:12:12
         12920 /25f8f3a5_BasicSplitPaneUI     06-FEB-2010 03:11:06
         42266 SI_GETCLRHSTGRFTR              06-FEB-2010 03:40:20
         15752 /2f494dce_JDWPThreadReference  06-FEB-2010 03:09:31
    11 rows selected.
    SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 ;
    OBJECT_ID OBJECT_NAME                    LAST_DDL_TIME
         37534 com/sun/mail/smtp/SMTPMessage  06-FEB-2010 03:46:14
         13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
         11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
         42266 SI_GETCLRHSTGRFTR              06-FEB-2010 03:40:20
         16695 /2940a364_RepIdDelegator_1_3   06-FEB-2010 03:38:17
         36539 sun/io/ByteToCharMacHebrew     06-FEB-2010 03:28:57
         26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
         14044 /d29b81e1_OldHeaders           06-FEB-2010 03:12:12
         36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
         12920 /25f8f3a5_BasicSplitPaneUI     06-FEB-2010 03:11:06
         15752 /2f494dce_JDWPThreadReference  06-FEB-2010 03:09:31
    11 rows selected.
    SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid order by last_ddl_time desc ;
    OBJECT_ID OBJECT_NAME                    LAST_DDL_TIME
         37534 com/sun/mail/smtp/SMTPMessage  06-FEB-2010 03:46:14
         13133 oracle/jdbc/driver/OracleLog$3 06-FEB-2010 03:45:44
         11749 /b9fe5b99_OraRTStatementComman 06-FEB-2010 03:43:49
         42266 SI_GETCLRHSTGRFTR              06-FEB-2010 03:40:20
         16695 /2940a364_RepIdDelegator_1_3   06-FEB-2010 03:38:17
         36539 sun/io/ByteToCharMacHebrew     06-FEB-2010 03:28:57
         26815 /7a628fb8_DefaultHSBChooserPan 06-FEB-2010 03:26:55
         14044 /d29b81e1_OldHeaders           06-FEB-2010 03:12:12
         36145 /4e492b6f_SerProfileToClassErr 06-FEB-2010 03:11:09
         12920 /25f8f3a5_BasicSplitPaneUI     06-FEB-2010 03:11:06
         15752 /2f494dce_JDWPThreadReference  06-FEB-2010 03:09:31
    11 rows selected.
    SQL> set autotrace traceonly
    SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid order by last_ddl_time desc
      2  ;
    11 rows selected.
    Execution Plan
    Plan hash value: 44968669
    | Id  | Operation                       | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |       |  1200 | 91200 |   180   (2)| 00:00:03 |
    |   1 |  SORT ORDER BY                  |       |  1200 | 91200 |   180   (2)| 00:00:03 |
    |*  2 |   HASH JOIN                     |       |  1200 | 91200 |   179   (2)| 00:00:03 |
    |*  3 |    VIEW                         |       |  1200 | 30000 |    98   (0)| 00:00:02 |
    |*  4 |     COUNT STOPKEY               |       |       |       |            |          |
    |   5 |      VIEW                       |       | 40617 |   475K|    98   (0)| 00:00:02 |
    |   6 |       INDEX FULL SCAN DESCENDING| T_IDX | 40617 |   793K|    98   (0)| 00:00:02 |
    |   7 |    TABLE ACCESS FULL            | T     | 40617 |  2022K|    80   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("T".ROWID="T1"."RID")
       3 - filter("RN">=1190)
       4 - filter(ROWNUM<=1200)
    Statistics
              1  recursive calls
              0  db block gets
            348  consistent gets
              0  physical reads
              0  redo size
           1063  bytes sent via SQL*Net to client
            385  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             11  rows processed
    SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 ;
    11 rows selected.
    Execution Plan
    Plan hash value: 882605040
    | Id  | Operation                | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT         |      |  1200 | 62400 |    80   (2)| 00:00:01 |
    |*  1 |  VIEW                    |      |  1200 | 62400 |    80   (2)| 00:00:01 |
    |*  2 |   COUNT STOPKEY          |      |       |       |            |          |
    |   3 |    VIEW                  |      | 40617 |  1546K|    80   (2)| 00:00:01 |
    |*  4 |     SORT ORDER BY STOPKEY|      | 40617 |  2062K|    80   (2)| 00:00:01 |
    |   5 |      TABLE ACCESS FULL   | T    | 40617 |  2062K|    80   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("RN">=1190)
       2 - filter(ROWNUM<=1200)
       4 - filter(ROWNUM<=1200)
    Statistics
              0  recursive calls
              0  db block gets
            343  consistent gets
              0  physical reads
              0  redo size
           1063  bytes sent via SQL*Net to client
            385  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             11  rows processed
    SQL> select object_id, object_name, last_ddl_time from t, (select rid, rownum rn from (select rowid rid from t order by last_ddl_time desc) where rownum <= 1200) t1 where rn >= 1190 and t.rowid = t1.rid ;
    11 rows selected.
    Execution Plan
    Plan hash value: 168880862
    | Id  | Operation                      | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |       |  1200 | 91200 |   179   (2)| 00:00:03 |
    |*  1 |  HASH JOIN                     |       |  1200 | 91200 |   179   (2)| 00:00:03 |
    |*  2 |   VIEW                         |       |  1200 | 30000 |    98   (0)| 00:00:02 |
    |*  3 |    COUNT STOPKEY               |       |       |       |            |          |
    |   4 |     VIEW                       |       | 40617 |   475K|    98   (0)| 00:00:02 |
    |   5 |      INDEX FULL SCAN DESCENDING| T_IDX | 40617 |   793K|    98   (0)| 00:00:02 |
    |   6 |   TABLE ACCESS FULL            | T     | 40617 |  2022K|    80   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("T".ROWID="T1"."RID")
       2 - filter("RN">=1190)
       3 - filter(ROWNUM<=1200)
    Statistics
              0  recursive calls
              0  db block gets
            349  consistent gets
              0  physical reads
              0  redo size
           1063  bytes sent via SQL*Net to client
            385  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
             11  rows processed
    SQL> select object_id, object_name, last_ddl_time from (select t1.*, rownum rn from (select * from t order by last_ddl_time desc) t1 where rownum <= 1200) where rn >= 1190 order by last_ddl_time desc ;
    11 rows selected.
    Execution Plan
    Plan hash value: 882605040
    | Id  | Operation           | Name | Rows     | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |     |  1200 | 62400 |    80   (2)| 00:00:01 |
    |*  1 |  VIEW                |     |  1200 | 62400 |    80   (2)| 00:00:01 |
    |*  2 |   COUNT STOPKEY       |     |     |     |          |          |
    |   3 |    VIEW            |     | 40617 |  1546K|    80   (2)| 00:00:01 |
    |*  4 |     SORT ORDER BY STOPKEY|     | 40617 |  2062K|    80   (2)| 00:00:01 |
    |   5 |      TABLE ACCESS FULL      | T     | 40617 |  2062K|    80   (2)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("RN">=1190)
       2 - filter(ROWNUM<=1200)
       4 - filter(ROWNUM<=1200)
    Statistics
         175  recursive calls
           0  db block gets
         388  consistent gets
           0  physical reads
           0  redo size
           1063  bytes sent via SQL*Net to client
         385  bytes received via SQL*Net from client
           2  SQL*Net roundtrips to/from client
           4  sorts (memory)
           0  sorts (disk)
          11  rows processed
    SQL> set autotrace off
    SQL> spool offAs you will see, the join query here has to have an ORDER BY clause at the end to ensure that records are correctly sorted. You can not rely on optimizer choosing NESTED LOOP join method and, as above example shows, when optimizer chooses HASH JOIN, oracle is free to return rows in no particular order.
    The query that does not involve join always returns rows in the desired order. Adding an ORDER BY does add a step in the plan for the query using join but does not affect the other query.

  • Need advice on pagination query

    Hello,
    I have the following example of a pagination query, but I heard that there might be some drawbacks to this query. Could anyone please let me know any problems that might happen with this? The user will provide inputs for p and q. Thanks.
    Select *
    From (select rownum as n, * from table order by x, y, z)
    Where n between p and q

    Hi,
    arizona9952 wrote:
    Hello,
    I have the following example of a pagination query, but I heard that there might be some drawbacks to this query. Could anyone please let me know any problems that might happen with this? The user will provide inputs for p and q. Thanks.
    Select *
    From (select rownum as n, * from table order by x, y, z)
    Where n between p and qIf there is anything in the SELECT clause along with *, then * has to be qualified by a table name or alias. (See the example below.)
    ORDER BY is applied after ROWNUM is assigned. For example, the qub-query might find x values 5, 8 and 3, and assign ROWNUM in that order, so you'd have
    x   ROWNUM
    5   1
    8   2
    3   3so if you were looking for the 2nd highest, you would get 8.
    I would use the analytic ROW_NUMBER function instead of ROWNUM.
    WITH  got_r_num      AS
         SELECT  x.*     -- not just *
         ,     ROW_NUMBER () OVER (ORDER BY x, y, z)  AS r_num
         FROM     table_x
    SELECT       *
    FROM       got_r_num
    WHERE       r_num     BETWEEN  :p
                AND      :Q
    ORDER BY  r_num
    ;To use ROWNUM, you would need 2 sub-queries. In the first, you would use ORDER BY, in the second, apply ROWNUM, and finally, in the main query, pick the values you wanted.

  • Help In Paginating Query output

    Hi All,
    I have a query which fetches 80000 records at one short. This fetching can be controlled by using the search criteria. But some times it needs to fetch all the records and populate on the screen. The query fetches and populates more than 50 columns and which takes more time.
    What i want is to fetch all the records but display only 10 of them at a time and provide pagination option like 1,2,3.... So when the user clicks on page 3, he will get the records 21-20 and page 4 records 31-40 and so on. If he want to again view page 1 then he should get records 1-10.
    How can i write a stored procedure to achive this and how to store the counters of this search?
    What is the best way to do this (alternate processes using PL/SQL)?
    Any explanations and solution to this will be of great help.
    Regards
    Swadhin

    Swadhin,
    One quick way I can think of is to have a sort order column in your
    table. The PL/SQL stored procedure would just take the upper and lower
    limits as parameters and query data. You just need to call
    the same procedure, passing it the appropriate upper and lower limits (which
    you would match against the sort order column). The limits would change
    for each link on a page.
    This approach would avoid dumping all the 80k records at one shot which is
    unnecessary. You can also avoid caching data on a client buffer.
    Just one way of doing it. There could be more efficient ways to achieve this.
    Rgds.
    Amogh

  • Sorting: ORDER BY DECODE Problem on Pagination Query

    Hi,
    I've been searching around the easiest way to perform a dynamic "ORDER BY" clause and the "DECODE()" clause solution seem to be exactly what I am looking for. Unfortunately, It seems the DECODE function is not returning a correct column name value (I think it is returning NULL) since I'm receive the result set as if there was no ORDER BY clause.
    I need some help to get through this!
    Here the version with DECODE (not working)
    It is a Procedure with frstRow, nbRows and var_order as parameters
    The output returns the rows as if no ORDER BY was used
    SELECT c1, c2
    FROM
    SELECT ROWNUM rn, arv.*
    FROM A_AWA_AR arv
    WHERE ROWNUM < (frstRow + nbRows - 1) -- show only some rows determined by procedure
    ORDER BY DECODE(var_order, 1, c1, 2, c2, c1) -- sort by var_order
    WHERE rn BETWEEN frstRow AND (frstRow + nbRows)
    AND ROWNUM <= nbRows
    Here the version without DECODE (working)
    The output returns the rows as expected - ordered by c2 column
    SELECT c1, c2
    FROM
    SELECT ROWNUM rn, arv.*
    FROM A_AWA_AR arv
    WHERE ROWNUM < (frstRow + nbRows - 1) -- show only some rows determined by procedure
    ORDER BY c2 -- sort by var_order
    WHERE rn BETWEEN frstRow AND (frstRow + nbRows)
    AND ROWNUM <= nbRows
    -----

    Here are some results I've been getting... I will try the best I can to explain my problem.
    And by the way the table A_AWA_AR is a VIEW maybe this can help.
    My problem -- I think -- is that I don't understand how DECODE works. I should be a conditional IF-ELSE-THEN-like function but its behavior is not returning what I'm expecting.
    I need a solution where I will be able to sort the first lets say 10 rows using ROWNUM to tag row position (in sub-query) then the main query should only show the rows from 3rd postion to 7th position in the main query (as an example) with RN BETWEEN 3 AND 7. My solution does not work when I use decode but works when i pass the column name directly.
    Here is a simple query returning the values in the order they are found in the view:
    SELECT ROWNUM rn, ROW_ID, SR_NUM
    FROM A_AWA_AR
    WHERE ROWNUM < 10 Results:
    RN                                     ROW_ID          SR_NUM                                                         
    1                                      1-100876        1-60476802                                                     
    2                                      1-10087G        1-60476812                                                     
    3                                      1-10087Q        1-60476822                                                     
    4                                      1-10088A        1-60476842                                                     
    5                                      1-10088K        1-60476852                                                     
    6                                      1-10088U        1-60476862                                                     
    7                                      1-100894        1-60476872                                                     
    8                                      1-10089E        1-60476882                                                     
    9                                      1-10089O        1-60476892                                                      Now this is the query & result I would like to obtain (this is done pretty fast since it returns as soon as it reaches 9 sorted rows):
    SELECT ROWNUM rn, ROW_ID, SR_NUM
    FROM A_AWA_AR
    WHERE ROWNUM < 10
    ORDER BY SR_NUMResults:
    RN                                     ROW_ID          SR_NUM                                                         
    1                                      1-1RV9J7        1-107274499                                                    
    2                                      1-1RVXIF        1-107305575                                                    
    3                                      1-1SHY65        1-108332861                                                    
    4                                      1-22FOSR        1-125023563                                                    
    5                                      1-236F3X        1-126270717                                                    
    6                                      1-28P5EB        1-135542675                                                    
    7                                      1-29P2VY        1-137219038                                                    
    8                                      1-29ZNFH        1-137712221                                                    
    9                                      1-2BLWQR        1-140430339                                                     But with decode even a simple pseudo decode:
    SELECT ROWNUM rn, ROW_ID, SR_NUM
    FROM A_AWA_AR
    WHERE ROWNUM < 10
    ORDER BY DECODE(1,1,SR_NUM)Results:
    RN                                     ROW_ID          SR_NUM                                                         
    1                                      1-100876        1-60476802                                                     
    2                                      1-10087G        1-60476812                                                     
    3                                      1-10087Q        1-60476822                                                     
    4                                      1-10088A        1-60476842                                                     
    5                                      1-10088K        1-60476852                                                     
    6                                      1-10088U        1-60476862                                                     
    7                                      1-100894        1-60476872                                                     
    8                                      1-10089E        1-60476882                                                     
    9                                      1-10089O        1-60476892                                                      Here is the structure I'm trying to get and works when passing a column name:
    SELECT *
    FROM
        SELECT ROWNUM rn, ROW_ID, SR_NUM
        FROM A_AWA_AR
        WHERE ROWNUM < 10
        ORDER BY SR_NUM
    WHERE rn BETWEEN 3 AND 7Results:
    RN                                     ROW_ID          SR_NUM                                                         
    3                                      1-1SHY65        1-108332861                                                    
    4                                      1-22FOSR        1-125023563                                                    
    5                                      1-236F3X        1-126270717                                                    
    6                                      1-28P5EB        1-135542675                                                    
    7                                      1-29P2VY        1-137219038                                                     Now with decode (not working):
    SELECT *
    FROM
        SELECT ROWNUM rn, ROW_ID, SR_NUM
        FROM A_AWA_AR
        WHERE ROWNUM < 10
        ORDER BY DECODE(1,1,SR_NUM)
    WHERE rn BETWEEN 3 AND 7Results:
    RN                                     ROW_ID          SR_NUM                                                         
    3                                      1-10087Q        1-60476822                                                     
    4                                      1-10088A        1-60476842                                                     
    5                                      1-10088K        1-60476852                                                     
    6                                      1-10088U        1-60476862                                                     
    7                                      1-100894        1-60476872                                                      Thanks for the support!

  • Query to retrieve rows from database

    hi ,
    I have a strange query " My oracle database contains around 4000 records. As it is not advisable to retrieve all the rows at the time. Is it possible for me to retrieve the rows 100 in a page and then the next hundred and then the next....... Not sure whether we can write a PL/SQL command for this or we need to tweak the database to show such options. Can anyone suggest on this please ????

    Hi,
    That's called a Pagination Query , and here's one way to do it:
    WITH     got_r_num     AS
         SELECT     x.*     -- or whatever columns you need
         ,     ROW_NUMBER () OVER (ORDER BY u_key)     AS r_num
         FROM     table_x
    --     WHERE     ...     -- If you need any filtering, put it here
    SELECT       *     -- or list all columns except r_num
    FROM       got_r_num
    WHERE       TRUNC (r_num / 100)     = :page_number
    ORDER BY  r_num
    ;U_key is whatever unique key determines the order. It can be a single column, or a comma-delimited list of expressions, as in any ORDER BY clause. fOR EXAMPLE:
    ...     ,     ROW_NUMBER () OVER ( ORDER BY       UPPER (last_name)
                             ,          UPPER (first_name)
                             ,          created_date     DESC
                           )     AS r_num

  • Query to get rows betwen x and y + table total row count

    Hi,
    I try get rows between e.g. 100 and 150 when I sort by some column
    My query is now like this
    SELECT  *
    FROM
      (SELECT a.*,
        row_number() OVER (ORDER BY OWNER ASC) rn,
        COUNT(1) over() mrn
      FROM (SELECT * FROM all_objects) a
    WHERE ROWNUM BETWEEN least(100,mrn) AND 150It is not very fast if I run that kind select from big table
    Any tips to optimize this query?
    Regards,
    Jari

    Hi,
    I'm so bad with SQL :(
    Here is sample where I need that kind query.
    http://actionet.homelinux.net/htmldb/f?p=100:504
    It looks standard Apex report but it is not.
    It is just test to use query to output html using htp package
    I send parameter start row, max rows, column I like order by.
    Now I do query for cursor
        /* Report query */
        l_sql := '
          SELECT * FROM(
            SELECT a.*, row_number() OVER (ORDER BY '
            || l_sort_col
            || ' '
            || l_sort_ord
            || ') rn, COUNT(1) over() mrn
            FROM(' || l_sql || ') a
          ) WHERE rn BETWEEN LEAST(' || l_start_row || ',mrn) AND ' || l_last_row
        ;Then I loop cursor and output html.
    You can order report by click heading and there is that pagination
    I did not know that I could find examples by "pagination query" =), thanks for that tip for both of you.
    I know Apex have reports ,
    but I need have features that Apex templates can not provide at least yet.
    So I have study that generating html tables using custom package instead Apex report should be best approach to get layouts I need.
    Regards,
    Jari
    Edited by: jarola on Jan 21, 2011 10:38 PM

  • 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 to set the classpath and path from the jsp to call  java class function

    Hi Exprets,
    I have a requirement to call a java class function which returns a hashmap object from the jsp. The java class in present in one jar file and that jar file is location somewhere in unix path. So the requirement is to set the classpath for that jar file and then create the object of the java class and then call the function.
    If any one know how to achieve it, please reply as soon as possible.
    thanks in advance,
    swapna soni.

    It is never advisable to store large data sets in the session. But it will depend on a lot of factors:
    1. How costly is the query retrieving the data from the database?
    If it's a complex query with lots of joins and stuff, then it will be better to store it in the session as processing the query each time will take a lot of time and will decrease performance. On the other hand if the query is simple then it's advisable not to store it in the session, and fetch it each time.
    2. Are there chances for the data to become stale within a session?
    In this case storing the data is session will mean holding the stale data till the user session lasts which is not right.
    3. How many data sets does the session already holds?
    If there are large no. of data sets already present in the session, then it's strictly not advisable to store the data in the session.
    4. Does the server employ some kind of caching mechanism?
    Using session cache can definitely improve performance.
    You will have to figure out, what is the best way analyzing all the factors and which would be best in the situation. As per my knowledge, session is the only place where session specific data can be stored.
    Also, another thing, if the data set retrieved is some kind of data to be displayed in reports, then it would be better to use a pagination query, which will retrieve only the specific no. of rows at a time. A navigation provided in the UI will retrieve the next/previous data set to display.
    Thanks,
    Shakti

  • ROWNUM Problem - Urgent

    Hi,
    I have a wierd problem with using ROWNUM for pagination. I'm using the query structure as below:
    SELECT * FROM ( SELECT A.*, ROWNUM rowno FROM (MY_ACTUAL_QUERY) A WHERE ROWNUM <= 200 ) WHERE rowno > 0
    In some cases of the MY_ACTUAL_QUERY, there exists records, but the pagination query is not returing records. If the where clause is replaced with "ROWNUM <= 361" or "ROWNUM <= 251" in some other cases, it returns records.
    Also, when some fields in the select clause are commented out, the query returns records. Is this a problem with Oracle itself or am I doing something wrong?
    Regards,
    Venkat

    Hi
    in the past.. i have a oracle bug whit pagination querys when i use a ROW_NUMBER ... I reported them at Oracle (bug #7033904)
    Text of bug at Metalink "...If a query contains multiple analytic functions and one of them is rank, dense_rank or row_number function and if there is a topn predicate (i.e. restricting the rows to topn ranks, dense_rank or row_number) in the outer query and if the results for the other analytic functions are incorrect, you may have encountered this bug...."
    This bug is already fixed on 11.2.0.1.0.
    My problem was by the optimizer mode, when the optimizer mode = all_rows the query return "bad results" and when the optimizer mode = rule return "good results"
    try to run the query with the optimizer = rule and let me know what happen ...
    alter session set optimizer_mode=rule; One Metalink note about that.. 734502.1
    Edited by: dask99 on Oct 23, 2008 1:50 PM

  • Microsoft azure table authentication stringtosign error

    I am having a problem with `stringtosign` authentication for azure table pagination query.
    This is the current `stringtosign` im using :
        GET\n\n\nFri, 05 Sep 2014 03:57:11 GMT\n/mystorageaccount/mytablename\nNextPartitionKey:1!20!UmFjZSBNZW1iZXJfNA--\nNextRowKey:1!12!TmFtZV85ODE-
    Is there anything wrong with this `stringtosign` authentication?
    The rest of the Headers are exactly the same as Fiddle. 
    **Example**
        GET /mytablename?NextPartitionKey=1%2120%21UmFjZSBNZW1iZXJfNA--&NextRowKey=1%2112%21TmFtZV85ODE- HTTP/1.1
        Host: mystorageaccount.table.core.windows.net
        x-ms-version: 2014-02-14
        x-ms-date: Fri, 05 Sep 2014 05:49:19 GMT
        Authorization: SharedKey mystorageaccount:GD2w4pqsllzIOixNF/AfFqLkZhYzLpjK67a8OI7j6Go=
        Accept: application/atom+xml
        Accept-Charset: UTF-8
        DataServiceVersion: 3.0;NetFx
        MaxDataServiceVersion: 3.0;NetFx
    I have read through both
     * http://msdn.microsoft.com/library/azure/dd179428.aspx
     * http://msdn.microsoft.com/en-us/library/azure/dd135718.aspx

    Hi Kai Wu Toh;
    As per the documentation here:
    http://msdn.microsoft.com/library/azure/dd179428.aspx (2009-09-19 Shared Key Format Section, point #4), you would need to
    convert all query parameters to lowercase. So your canonicalized resource string should be:
    GET\n\n\nFri, 05 Sep 2014 03:57:11 GMT\n/mystorageaccount/mytablename\nnextpartitionkey:1!20!UmFjZSBNZW1iZXJfNA--\nnextrowkey:1!12!TmFtZV85ODE-
    Give it a try. let me know if you still have further queries.
    Warm regards
    Prasant

  • Sorting with Name

    hi
    i have procedure with sorting technic..
    for sorting i have used code like this
    ......select ...... .. select ......  rownum rn from table_name
                             where cond...
             where pagenumber ......  pagesize........
    but now i want display result according to sorting,
    with alphabetic sorting.
    means if a user want to search name like start with name "M"
    i want to display result with starting letter is "M" as follows...
    and also user want to move <<next> <<last>> <<first>> <previouse>>for this any doc's or sample example or any ideas
    Edited by: OraclePLSQL on Dec 30, 2010 5:31 PM

    Hi,
    ROWNUM shows the order in which a row was received.
    If the source of the data is a table, then the order is undefined, and ROWNUM is arbitrary.
    If the source of the data is a sub-query or a view, then ROWNUM reflects the ORDER BY clause of that sub-query or view. If there is no ORDER BY clause, then ROWNUM is arbitrarty.
    If you want a Pagination Query , where you each page has a given size (it looks like 3 in your example), and you want to display only one given page (page #2 in your example), then you can use ROWNUM, but assign ROWNUM after the data is ordered.
    So you could modify the query you posted like this:
    SELECT * FROM
       SELECT ENAME,    EMPNO,    SAL
       ,      ROWNUM   AS RN               -- ROWNUM is meaningful here (source is ordered)
       FROM
         SELECT    ENAME, EMPNO, SAL          -- No ROWNUM here (source is not ordered)
         FROM      EMP
    --   WHERE     ename     LIKE 'M%'          -- Any filtering goes here
         ORDER BY  ename
       WHERE ROWNUM <((2*3)+1)
    WHERE RN >= (((2-1)*3)+1)
    ORDER BY  rn
    ;Remember to use an ORDER BY clause in the main query, if you want the output sorted.
    Output (using scott.emp):
    ENAME           EMPNO        SAL         RN
    CLARK            7782       2450          4
    FORD             7902       3000          5
    JAMES            7900        950          6This is the 2nd page; ADAMS, ALLEN and BLAKE would be on page 1.
    I think the analytic ROW_NUMBER function is better than ROWNUM for this kind of thing.
    Also, consider using variables instead of the "magic numbers" 2 and 3 in your WHERE clauses.
    The following query produces the same results as the query above:
    -- How many rows should appear on each page (except maybe the last page)?
    VARIABLE  page_size     NUMBER
    EXEC  :page_size := 3;
    -- Which page do we want to display in this query?
    VARIABLE  page_num     NUMBER
    EXEC  :page_num  := 2;
    WITH     got_rn     AS
         SELECT     ename, empno, sal
         ,     ROW_NUMBER () OVER (ORDER BY ename)     AS rn
         FROM     emp
    --     WHERE     ename     LIKE 'M%'     -- Any filtering goes here
    SELECT       *
    FROM       got_rn
    WHERE       CEIL (rn / :page_size)     = :page_num
    ORDER BY  rn
    ;

  • Write as single statement insted of two

    Hi,
    I was tried to write as single select statement instead of two but i didn't get any idea.Is there any chance to write as single select ?
    IF (v_year   < 2010) OR (v_year = 2010 AND v_month = 'MAY') THEN
        OPEN v_resultset FOR SELECT * FROM
        (SELECT q.* ,
          ROWNUM          AS rowindex,
          COUNT(*) over() AS record_count
        FROM
          (SELECT SubLvl.Tran1
            || ' '
            || SubLvl.Tran2 AS SubLvl_Trans,
            E1
            || ' '
            || E2 AS E_Text
          FROM
            (SELECT DISTINCT dt.long_translation AS Tran1,
              dt2.long_translation               AS Tran2,
              dt.english_text                    AS E1 ,
              dt2.english_text                   AS E2
            FROM IBIS.candidate_subject_registration csr,
              IBIS.data_translation dt,
              IBIS.data_translation dt2,
              IBIS.subject_availability csa
            WHERE csr.YEAR                = v_year
            AND csr.MONTH                 = v_month
            AND csr.main_school           = v_school
            AND csr.programme             = 'DIPLOMA'
            AND csr.withdrawn             = 'N'
            AND csr.subject              != 'REF PROJECT'
            AND csr.subject_option        = csa.subject_option
            AND csr.lvl                   = csa.lvl
            AND csr.YEAR                  = csa.YEAR
            AND csr.MONTH                 = csa.MONTH
            AND csr.language              = csa.language
            AND csa.type_of_availability != 'SBS'
            AND csa.type_of_availability != 'none'
            AND csr.language              = dt.language
            AND dt.english_text           = csa.subject_option
            AND dt.language               = v_language
            AND dt.type                   = 'SUBJECT'
            AND dt2.english_text          = csr.lvl
            AND dt2.language              = 'ENGLISH'
            AND dt2.type                  = 'LEVEL'
            ORDER BY Tran1
            ) SubLvl
          )q
        )sq WHERE rowindex >= v_startrow AND rowindex <= (v_startrow + (v_maxrows - 1));
      ELSE
        OPEN v_resultset FOR SELECT * FROM
        (SELECT q.* ,
          ROWNUM          AS rowindex,
          COUNT(*) over() AS record_count
        FROM
          (SELECT SubLvl.Tran1
            || ' '
            || SubLvl.Tran2 AS SubLvl_Trans,
            E1
            || ' '
            || E2 AS E_Text
          FROM
            (SELECT DISTINCT dt.long_translation AS Tran1,
              dt2.long_translation               AS Tran2,
              dt.english_text                    AS E1 ,
              dt2.english_text                   AS E2
            FROM IBIS.candidate_subject_registration csr,
              IBIS.data_translation dt,
              IBIS.data_translation dt2
            WHERE csr.YEAR       = v_year
            AND csr.MONTH        = v_month
            AND csr.main_school  = v_school
            AND csr.programme    = 'DIPLOMA'
            AND csr.withdrawn    = 'N'
            AND csr.subject     != 'REF PROJECT'
            AND dt.english_text  = csr.subject_option
            AND csr.language     = dt.language
            AND dt.language      = v_language
            AND dt.type          = 'SUBJECT'
            AND dt2.english_text = csr.lvl
            AND dt2.language     = 'ENGLISH'
            AND dt2.type         = 'LEVEL'
            ORDER BY Tran1
            ) SubLvl
          )q
        )sq WHERE rowindex >= v_startrow AND rowindex <= (v_startrow + (v_maxrows - 1));
      END IF;

    Hi,
    I'm willing to share what I know about SQL to help solve this. Are you willing to share what you know about the problem? If so, why not say what the difference between the two queries is, rather than ask people to figure it out. This is just the kind of thing that should be indicated by comments in the code itself. That way, it will help you, or whoever has to maintain the code, in the future.
    If the two queries are the same, except that the csa table only matters before May, 2010, then you can do something like this:
    -- v_date is a DATE
    v_date := TO_DATE ( TO_CHAR (v_year, 'FM0000') || v_month
                         , 'YYYYMONTH'
    OPEN v_resultset FOR SELECT * FROM
        (SELECT q.* ,
          ROWNUM          AS rowindex,
          COUNT(*) over() AS record_count
        FROM
          (SELECT SubLvl.Tran1
            || ' '
            || SubLvl.Tran2 AS SubLvl_Trans,
            E1
            || ' '
            || E2 AS E_Text
          FROM
            (SELECT DISTINCT dt.long_translation AS Tran1,
              dt2.long_translation               AS Tran2,
              dt.english_text                    AS E1 ,
              dt2.english_text                   AS E2
            FROM IBIS.candidate_subject_registration csr,
              IBIS.data_translation dt,
              IBIS.data_translation dt2
            WHERE csr.YEAR                = v_year
            AND csr.MONTH                 = v_month
            AND csr.main_school           = v_school
            AND csr.programme             = 'DIPLOMA'
            AND csr.withdrawn             = 'N'
            AND csr.subject              != 'REF PROJECT'
         AND (    v_date               >= DATE '2010-05-01'
             OR    (        (csr.lvl, csr.year, csr.month, csr.language)
                    IN  ( SELECT  lvl,     year,     month,     language
                         FROM     ibis.subject_availablility
                   WHERE     type_of_availability     NOT IN ('SBS', 'none')
            AND csr.language              = dt.language
            AND dt.english_text           = csa.subject_option        -- WRONG: see 2nd and 3rd messages following this one
            AND dt.language               = v_language
            AND dt.type                   = 'SUBJECT'
            AND dt2.english_text          = csr.lvl
            AND dt2.language              = 'ENGLISH'
            AND dt2.type                  = 'LEVEL'
            ORDER BY Tran1
            ) SubLvl
          )q
        )sq WHERE rowindex >= v_startrow AND rowindex <= (v_startrow + (v_maxrows - 1));If you'd care to post CREATE TABLE and INSERT statements for some sample data, and the results you want from that data, then I could test it. You should post two sets of results from the same data: one where v_date is before May, 2010, and the other where v_date is May, 2010 or later.
    Information about dates belongs in DATE columns. You're only making things harder by having separate year and month columns. Use a DATE instead. It's easy to extract just the year or month from a DATE if you ever need them separately.
    Is this a pagination query, where you're displaying maxrows rows at a time?
    If so, then instead of running the queriy N times to get N pages, it sould be more efficient to get all of the results at the same time, and loop through the results to display maxrows rows at a time.
    Edited by: Frank Kulash on May 28, 2012 6:29 AM
    Corrected conditions involving subject_availability
    Edited by: Frank Kulash on May 29, 2012 3:45 AM
    Mistake involving alias csa noted, after Rocky (below)

  • Issue While executing the Query for Pagination using ROWNUM with like

    Issue While executing the Query for Pagination using ROWNUM with like.
    Database is Oracle11G.
    Oracle Database Table contains 8-9 lakh records
    1) SQL equal (=)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920'
    Execution Time:- 0.00869245 seconds
    Returns 2 resultsets
    2) SQL like (one %)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE = 'KMF22600920%'
    Execution Time:- 0.01094301 seconds
    Returns 2 resultsets
    3) SQL like (two%)
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE A.REFERENCE like '%KMF22600920%'
    Execution Time:- 6.43989658 seconds
    Returns 2 resultsets
    In Pagination, we are using Modified version of SQL Query 3) with ROWNUM as mentioned below :-
    4) SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) WHERE RNUM > 0
    Execution Time:- Infinite
    ResultSets:- No as execution time is infinite
    a) Instead of like if we use = in the above query it is returning the 2 resultsets (execution time 0.02699282 seconds)
    b) Instead of two % in the above query, if use one example REFERENCE like 'KMF22600920%' it is returning the 2 resultsets (execution time 0.03313019 seconds)
    Issue:- When using two % in like in the above query i.e. REFERENCE like '%KMF22600920%' AND ROWNUM <= 20 ) , it is going to infinite.
    Could you please let us know what is the issue with two % used in like and rownum
    5) Modified version of Option1 query (move out the RNUM condition AND RNUM <= 20)
    SELECT * FROM (
    SELECT /*+ FIRST_ROWS(n) */ ROWNUM RNUM, A.* FROM LINE A
    WHERE REFERENCE like '%KMF22600920%' ) WHERE RNUM > 0 AND RNUM <= 20
    Execution Time:- 7.41368914 seconds
    Returns 2 resultsets
    Is the above query is best optimized query which should be used for the Pagination or still can improve on this ?

    This would be easier to diagnose if there was an explain plan posted for the 'good' and 'bad' queries. Generally speaking using '%' on both sides precludes the use of any indexes.

  • Sql Query(Updateable Report) with pagination

    Hi,
    We're on APEX 3.2 I have a question on Sql Query(Updateable Report) and pagination. I have an updateable report which we have set to show 20 rows. When the userwhi has more than 20 rows enters the data and clicks next the data disappears. I have been reviewing other posts, but haven't come to a clear conclusion on how to prevent this from happening. I have been trying to use javascript to show a save popup when clicking 'Next' Any help is appreciated.
    Thanks,
    Joe

    any ideas?

Maybe you are looking for

  • Your iOS 7 has broken my ipad2 wifi, how can I have this replaced? Thank you! 3p's

    1Lester12 30-Mar-2014 16:59 I had posted this, but directd n wrong forum,2 x's 29-Mar-2014 04:34 Your ios 7 has broken my wifi connection on my ipad. I hve a brand new router 30hrs old. My ipad 2 is not jail broken, jst ios 7 broken! Turning my route

  • Expert help needed with HSlider

    I am using HSlider to filter minimum/maximum product prices from an ArrayCollection and am having trouble with the slider thumbs: The thumbs are supposed to appear at the extreme left and right ends of the slider. It works fine when I hardcode the pr

  • I need help opening an existing website

    I am trying to open an existing website and edit it.  When i click get I see a folder and when I open it in local view all I get is the graphics.

  • How to handle  a large table using a JTable

    I want to create a lookup for the customer master file. And there is over 5000 records. so, what is the way to handle this case? ( if adding the all elements to vector or array, i think it is very time consuming and request many memory) thank you.

  • "Call Library Function" absent from performance profiling

    Hello, I'm trying to optimize my VI execution time by using the "Profile Performance and Memory" window. The VI takes 25 sec to run, however the profiler reports something like 25 ms, if I understand correctly. I know the 25 sec includes all other pr