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

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 help to format the output of the query.

    First of all i would like to say I m newbi in oracle query
    and of course thanks to read the thread.
    I have a problem formatting a query output.
    Actually the query is like the following :
    select a1
    ,b1
    ,c1
    from table
    where id.table=1
    UNION
    select a2
    ,b2
    ,c2
    from table2
    where id.table2=1
    order by 1;
    exit;
    my actual output
    a1 b1 c1
    a2 b2 c2
    a1 b1 c1
    a2 b2 c2
    my desired output
    a1 b1 c1
    a2 b2 c2
    a1 b1 c1
    a2 b2 c2
    So what i need is an empy row between the groups of results
    and to shift the union query.
    thanks in advance

    SQL>select * from t1;
            C1         C2         C3
             1          2          3
             2          3          4
             3          4          5
    SQL>select * from t2;
            C1         C2         C3
            30         40         50
            20         30         40
            10         20         30
    SQL>select c1,c2,c3
      2  from( select c1,c2,c3,1 flg
      3           from t1
      4           union all
      5           select c1,c2,c3,2
      6           from t2
      7           union all
      8           select null,null,null,1
      9           from dual)
    10  order by flg,c1,c2,c3 nulls last;
            C1         C2         C3
             1          2          3
             2          3          4
             3          4          5
    <br>
            10         20         30
            20         30         40
            30         40         50
    7 rows selected.
    Funny.......                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I ask to help on pagination

    I ask to help on pagination
    All greetings! For me a question on pagination
    Has made pagination for the directory of articles on a site, but at addition of new articles in a database, having divided into pages proceeds in a format
    BACK 1 2 3 4 5 6 7 8 NEXT
    So can proceed indefinitely (to 100-200 pages etc.).
    I wish to make, that pagination was in such format:
    BACK 1 2 3 4 5 6 7 8 9 10... NEXT
    That is, that pages were displayed to 10, and the others were not displayed, and began to be displayed, when the user has reached 10 pages, for example:
    BACK... 11 12 13 14 15 16 17 18 19 20 NEXT
    CODE:
    <cfquery name="getArticle" datasource="Article" result="resultInfo">
    SELECT Articles.Id, Articles.title, Articles.anonce, Articles.disc, Articles.add_date, Articles.image, Articles.tag
    FROM Articles
    </cfquery>
    <!--- set how many records you want to display per page --->
    <cfset Result_Per_Page="1">
    <!--- get the total record count from q_fetch query --->
    <cfset Total_Records="#getArticle.recordcount#">
    <!--- set the default value for the offset record set number --->
    <cfparam name="URL.offset" default="0">
    <!--- the limit result set(i.e., end row) --->
    <cfset limit=URL.offset+Result_Per_Page>
    <!--- page results start from? --->
    <cfset start_result=URL.offset+1>
    <!--- make sure that the initial start row is starting from 1 --->
    <cfset URL.offset=URL.offset+1>
    <!--- if the record is their more than one page so show the navigation bar --->
    <cfif Total_Records GT Result_Per_Page>
    <br>
    <!--- Create Previous Link --->
    <cfif URL.offset GT Result_Per_Page>
    <!--- Previous Link Offset --->
    <cfset prev_link=URL.offset-Result_Per_Page-1>
    <cfoutput><b class="numpage_link"><a href="#cgi.script_name#?offset=#prev_link#">BACK</a></b></cfoutput>
    </cfif>
    <!--- Find out how many pages are there for display  --->
    <cfset Total_Pages=ceiling(Total_Records/Result_Per_Page)>
    <!--- now loop it for navigation page numbers --->
    <cfloop index="i" from="1" to="#Total_Pages#">
    <cfset j=i-1>
    <!--- create offset value for page numbers --->
    <cfset offsetvalue=j*Result_Per_Page>
    <!--- deactivate the link if the page number is current page --->
    <cfif offset_value EQ URL.offset-1 >
    <cfoutput><b class="numpage">#i#</b></cfoutput>
    <cfelse>
    <cfoutput><b class="numpage_link"><a href="#cgi.script_name#?offset=#offset_value#">#i#</a></b></cfoutput>
    </cfif>
    </cfloop>
    <!--- create Next Link --->
    <cfif limit LT Total_Records>
    <!--- Next Link Offset --->
    <cfset next_link=URL.offset+Result_Per_Page-1>
    <cfoutput><b class="numpage_link"><a href="#cgi.script_name#?offset=#next_link#">NEXT</a></b></cfoutput>
    </cfif>
    </cfif>
    <!--- display the result on the screen --->
    <cfloop query="getArticle" startrow="#URL.offset#" endrow="#limit#">
    <cfoutput>
    <div class="center_item_line">
    <h4>#DateFormat(Now())# <p>#getArticle.tag# </p></h4>
    <div class=center_item_img><a href="article.cfm?ID=#getArticle.Id#"><img src="../images/#getArticle.image#" width="180" height="133" alt="Новости зарубежной недвижимости"></a></div>
    <h4><a href="article.cfm?ID=#getArticle.Id#">#getArticle.title#</a></h4>
    <p>#getArticle.anonce# </p>
    <div style='clear:both;'></div>
    <br/>
    <div class="line"></div>
    </div>
    </cfoutput> <br>
    </cfloop>
    </body>

    You might want to take a look at the PaginationCFC project at RIAForge.com:
    http://paginationcfc.riaforge.org/
    It looks like a very useful pagination library that could help you manage your large data set output.

  • Help in XML Report output

    Hi Experts,
    I have created the XML report which will generate the output in EXCEL format. I have used the template(rtf) to generate the output. I am facing the critical issue the output file (excel) is giving output with headings( ex: empno,ename,job..)even if there is no record count in the query.
    But some times it gives the empty file(excel) without the heading information if the record count is zero.
    Could anyone suggest me to solve this error.
    Any solution or link will be great help for me. Waiting for your valueable reply
    Thanks in Advance,
    Ravi.

    Hi,
    Please see if this thread helps.
    XML publisher output report in excel format
    Re: XML publisher output report in excel format
    Regards,
    Hussein

  • Issue In query output

    Hello Gurus,
    I am having an issue with query output.Please find below the details of it
    Unsold claims: Total---> 200
    Dispatch: Total--->118,086
    Unsold claims/dispatch--->0.001694
    This should be the output but its coming --.0033120 because itu2019s dividing with max value in dispatch which is 60,386.
    Reason: The aggregation property of Dispatch is max value. I am not supposed to do any changes in Modeling. So can we do any thing at reporting level to get the desired output?
    Desired output---->0.001694
    Output coming---->.0033120
    Please help me in getting the desired output at query level.
    Regards,

    solved with the help of nested exception aggregation

  • Change layout of Adhoc query output list for Custom infotype

    Hi All,
    The fields in the Infoset query output on a custom infotype are aligned with the fields u2018payment typeu2019 and u2018amountu2019 appearing repeatedly(in columns) as declared in the Infotype and the output will be a long horizontal list.
    Instead, the requirement is that the output list should show vertically so that If I choose u2018Payment Typeu2019 and u2018Amountu2019 as output fields, it will show a long vertical list as in the case of a standard infotype (IT0008).
    Also, this way enables user to use Payment Type as a selection criteria so as to just pulling the needed payment type. When we use IT0008 in the infoset it works fine but in custom IT it does not work.
    Any pointers/suggestions on how we can achieve this would be helpful.

    Hi yu liang,
                     You can find vendor list having Vendor No. & without showing total liability for every vendor.
    after executing the report,
    1.You need to select "change layout (ctrl+F8)",
    a small window comes, it has two part -> column content & hidden fields.
    then u select "Vendor" from hidden field & move it to column content.
    2. at column content there is a column named "Total". u need to remove check for your column name "amount".
    now select "copy" button or enter. u will find the req. report.
    u can save it also by ur name.
    hope its helpful to u.......
    plz, reward points as a way of thanks if helpful...

  • To download the query output to falt file

    Hi all,
    i have a query which i know will give more than 65k records as the output for a selection.
    i cannot run this query in excel due to its limitation.
    if i run on web i cannot download this as downloading is happening to excel file only.
    The customer ideally wants to download the query result to a text file(csv,tab-delimited etc) which inturn it will upload to MS-Access.
    How do i achieve this?
    SAP has given response use try using these options:
    1.open interfaces to receive the output of a query via the MDX language.
    2.open hub tool as it is designed for big amounts of data.(i suppose this is not possible as i want to download query output not the data target contents)
    how do i achieve my scenario with option 1?
    Are there any alternatives??
    Any useful help will be rewarded.
    Regards,
    Dhanya.

    hi vivek,
    thnks for the useful reply.
    i have some problem with my ID,hence loggin in through my coleague's ID.
    i will assign u points as i get logged in.
    I did as u said by downloading it to unconverted format.
    the file got download to a text file.where the output has
    1.header rows(10 lines almost)
    2.the values r coming in single quotes e,g:
    '144000023073      'TAAS SETTLEMENT CONV 738 '19333000   '30.09.2006          '0.000
    how can i remove all this?
    Regards,
    Dhanya
    I

  • Query Output to download in flat file through APD  or other means?

    Hello Experts,
    I am currently on BW3.5 system and have requirement to load query output in flat file in .csv format. I checked the option of APD but looks like we cant directly load the query output in flat file like in APD (BW  3.5 system) .
    One way i can think of it...load  the query output in transactional ODS and built an infospoke on it to write into flat file.
    Please advice if there are any better methods to store the query output in flat files.
    Thanks!

    Hi,
    Use RSCRM_BAPI.
    See
    Re: RSCRM_Bapi
    See the help on RSCRM_BAPI
    Re: Running Quaries automatically and saving them in as a Excel file in Server
    Re: Data transfer to external systems
    Re: Loading from a Custom R/3 Table
    Re: How can I schedule my Bex report to execute in background
    Re: How can I insert the RSCRM_BAPI into Process chain?
    Thanks
    Reddy

  • Need help for a query

    Dear all,
    I have data in a table with 3 columns.
    Tabke name---test & columns are ....
    Proeductioncode varchar2(5);
    revisionno varchar2(3);
    dateadopted char(8);
    SELECT PRODUCTIONCODE,
    REVISIONNO,
    dateadopted
    FROM test
    where
    productioncode ='CI50E';
    output should be
    productioncode revisionno dateadopted
         CI50E     004     20110125     
         CI50E     001     20101104     
         CI50E     003     20110320     
         CI50E     002     20101214     
    My requirement is
    I wanna display records which are dateadopted is > sysdate and
    one record which is less than sysdate, which is the max(<sysdate)..
    from the data above, the output should be
    CI50E     003     20110320     
    CI50E     004     20110125     
    Please help me get this output. we need to write it in a select query.

    Sorry I don't have a database available to test - missed to join by productioncode :( grouping by revisionno caused more than one row being returned :(
    No need to send data. I added a data providing subquery. Will take shot when I get to the database, but I might not be able to post from the office
    with
    /* generating test data */
    test as
    (select 'CI50E' productioncode,'004' revisionno,'20110125' dateadopted from dual union all /* 003 if increasing by date */
    select 'CI50E','001','20101104' from dual union all
    select 'CI50E','003','20110320' from dual union all                                        /* 004 if increasing by date */
    select 'CI50E','002','20101214' from dual union all
    select 'XI50Y','001','20110220' from dual union all
    select 'XI50Y','002','20110220' from dual union all
    select 'XI50Y','003','20110304' from dual 
    /* end of test data generation */
    SELECT productioncode,revisionno,dateadopted
      FROM (select productioncode,revisionno,dateadopted
              from test a
             where (dateadopted > to_char(sysdate,'yyyymmdd'))
                or dateadopted = (select max(dateadopted)
                                    from test
                                   where productioncode = a.productioncode
                                     and dateadopted < to_char(sysdate,'yyyymmdd')
    ORDER BY PRODUCTIONCODERegards
    Etbin
    Edited by: Etbin on 20.2.2011 21:58
    did some alignment
    Edited by: Etbin on 21.2.2011 7:39
    missing right parenthesis added, group by clause removed since there is just a single product
    Edited by: Etbin on 21.2.2011 7:52
    some more data edit

  • Help with my query

    Hello all,
    Total newbie to this pl/sql stuff. So, deseperately need help in my query.
    BOOKING_ID     BOOKING_STATUS     BOOKING_DATE     BOOKING_TIME     BOOKING_DATE_TIME
    1234567     CANCELLED     20090301     37252     5/1/2010 10:20
    1234567     CANCELLED 20090301     44229     5/1/2010 12:17
    1234567     BOOKED     20090301     39462     5/1/2010 10:57
    1234567     CANCELLED     20090301     43549     5/1/2010 12:05
    9671111     BOOKED     20090301     68124     5/1/2010 12:57
    9671111     CANCELLED     20090301     45001     5/1/2010 12:05
    How do I write my query such that I would get the following results:
    BOOKING_ID     BOOKING_STATUS     BOOKING_DATE     BOOKING_TIME     BOOKING_DATE_TIME
    9671111     BOOKED     20090301     68124     2/4/2010 12:17
    Basically, I am looking at the latest BOOKING_TIME and making sure the BOOKING_STATUS=BOOKED, if not, don't even bother bring back the result. Hence, you see that BOOKING_ID=1234567 is not required since at the latest BOOKING_TIME=44229, the BOOKING_STATUS=CANCELLED.
    Any help is greatly appreciated.
    Thank you in advance for your help.
    Stanley Ho

    Hi, Stanley,
    Welcome to the forum!
    Whenever you have a question, please post your sample data in a form that people can actually use. CREATE TABLE and INSERT statements are perfect.
    For example:
    CREATE TABLE     booking
    (     booking_id          NUMBER (8)
    ,     booking_status          VARCHAR2 (10)
    ,     booking_date_time     DATE
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'CANCELLED',        TO_DATE ('5/1/2010 10:20', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'CANCELLED',        TO_DATE ('5/1/2010 12:17', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'BOOKED',        TO_DATE ('5/1/2010 10:57', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (1234567,        'CANCELLED',        TO_DATE ('5/1/2010 12:05', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (9671111,        'BOOKED',        TO_DATE ('5/1/2010 12:57', 'MM/DD/YYYY HH24:MI'));
    INSERT INTO  booking (booking_id, booking_status, booking_date_time)
                  VALUES (9671111,        'CANCELLED',        TO_DATE ('5/1/2010 12:05', 'MM/DD/YYYY HH24:MI'));What you want is called a Top-N Query .
    Here's one way to do it:
    WITH     got_rnum  AS
         SELECT     booking.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  booking_id
                                   ORDER BY          booking_date_time     DESC
                           ) AS rnum
         FROM    booking
    SELECT     booking_id
    ,     booking_status
    ,     TO_CHAR (booking_date_time, 'YYYYMMDD')               AS booking_date
    ,     TO_CHAR (booking_date_time, 'SSSSS')               AS booking_time
    ,     TO_CHAR (booking_date_time, 'MM/DD/YYYY HH24:MI')     AS booking_date_time
    FROM     got_rnum
    WHERE     rnum          = 1
    AND     booking_status     = 'BOOKED'
    ;Notice that you don't need PL/SQL to do this; plain old SQL is good enough.
    Of course, if you're using PL/SQL for other reasons, you can use a query like this within PL/SQL.
    Dates (including time of day) should always be stored in DATE columns.
    If you have a DATE column, like booking_date_time, then there's no need for redundant date and time columns.
    You can always display just the year-month-day, or just the time, in any format, as I did above.
    The output from the query above, with the data above, is:
    BOOKING_ID BOOKING_ST BOOKING_ BOOKI BOOKING_DATE_TIM
       9671111 BOOKED     20100501 46620 05/01/2010 12:57I realize the booking_date and booking_time columns aren't quite what you posted. If they are not derivable from booking_date_time, then you probably do need separate columns for them, and those columns can easily be added to the query above.
    Edited by: Frank Kulash on Feb 5, 2010 4:41 PM
    KEEP (DENSE_RANK ...) , like Max used below, is a great tool to have in your kit. The problem with it is that you have to repeat a lot of stuff for every column, so the more columns you have in your output, the more tedious it gets. ROW_NUMBER sclaes much better, and is adaptable to more situations. I suggest you master ROW_NUMBER first, and look into KEEP (DENSE_RANK ...) later.

  • Need Help on Sql Query

    Hi,
    I have a client requirement to show a report on the device availability. The report should show the output as
    Node Availability%
    Formula for Availability = (Total No. of Failed/Total No. rows) * 100
    My Oracle Table has the following data
    NODE     SUMMARY
    172.16.10.55     Default Interface Ping fail for 172.16.10.55: ICMP timeout
    172.16.10.55     Default Interface Ping restore for 172.16.10.55
    172.16.10.55     Default Chassis Ping restore for 172.16.10.55
    172.16.10.55     Default Chassis Ping fail for 172.16.10.55: ICMP timeout
    172.16.10.55     Default Chassis Ping restore for 172.16.10.55
    172.16.10.55     Default Chassis Ping fail for 172.16.10.55: ICMP timeout
    172.16.10.55     Default Chassis Ping fail for 172.16.10.55: ICMP timeout
    172.16.10.55     Default Interface Ping restore for 172.16.10.55
    172.16.10.55     Default Interface Ping fail for 172.16.10.55: ICMP timeout
    172.16.10.56     Default Chassis Ping restore for 172.16.10.56
    172.16.10.56     Default Interface Ping fail for 172.16.10.56: ICMP timeout
    172.16.10.56     Default Chassis Ping fail for 172.16.10.56: ICMP timeout
    172.16.10.56     Default Chassis Ping restore for 172.16.10.56
    172.16.10.56     Default Chassis Ping fail for 172.16.10.56: ICMP timeout
    172.16.10.56     Default Chassis Ping restore for 172.16.10.56
    172.16.10.56     Default Chassis Ping restore for 172.16.10.56
    172.16.10.56     Default Interface Ping fail for 172.16.10.56: ICMP timeout
    In the above table the Summary column has the details like 'Ping fail' , 'Ping restore' for each Node. So, for each Node I have to compute the Total Ping Fail / (Total Ping Fail + Ping Restore) * 100 to compute the availability %.
    My output should be like the below
    Node Availability%
    172.16.10.55 55.55
    172.16.10.56 54
    Can someone please help me with query.
    I appreciate your help in advance.
    Thanks.
    Regards,
    RaviShankar.

    My Oracle Table has the following dataThat's great, but if you want maximum response to your question, then post CREATE TABLE + INSERT INTO statements.
    I currently do not have the time to turn your data into them.
    And always post the database version you're using.
    http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
    Also use the {noformat}{noformat} tag in order to post examples that benefit from staying formatted and thus readable when posted on the forum.
    Simply put the tag before and after your examples.
    For example, when you type:
    {noformat}select *
    from dual;{noformat}
    it will appear as:select *
    from dual;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Jump to search term in a query output...

    Hi,
    I have the results of a query outputted in a table. Depending
    on the user, this can be a longish query - maybe 100+ results. All
    these results have a checkbox next to them. The user checks the
    records they need to select, then submits the form to take that
    list of records in the "check" variable to another page which
    processes it.
    What I'd like to be able to do is provide a search box on top
    of this table, for the user to type in a search term in the record
    they want to find. Then, I'd like the page to jump down to that
    record so the user can check it. But here's the kicker - I don't
    want to lose any other already-checked boxes. So the form variable
    needs to persist, even if this is done multiple times.
    Any ideas on how this might be accomplished? I don't mind if
    the search has to be tied just to one field, etc. And I'm not
    asking anyone to write the code for me. Just point me in the
    direction of the right technique/technology, if ya can.
    Thank you!

    Hi,
    It might be worth checking out some of the Ajax libraries for
    this. jQuery (
    http://jquery.com) has a plugin
    called ScrollTo (
    http://plugins.jquery.com/project/ScrollTo)
    that lets you easily scroll to a specific position or element (or
    other) item on a page. The developer has more details on his site (
    http://flesler.blogspot.com/2007/10/jqueryscrollto.html).
    You could use the ScrollTo plugin in concert with one of the
    Auto Complete plugins for jQuery (one of them:
    http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/).
    Hope that helps get you started.

  • BEX iView - Remove unwanted tabs in the query output

    Hi
    EP SP 6.0 SP21
    BW 3.5
    We have created a couple of BEX iViews that reported from the BW system. But we do not want some of the options provided by the BEX iView like the sorts, characteristics, etc and wanted to hide the query tabs that we are not using like informaiton broadcasting etc.
    Has any one been succesful in removing this unwanted options from the BEX query output? I couldn't find anything in the iView properties that helped me with the issue.
    Appreciate any suggestion on this item.
    regards
    Raj

    Hi Raj,
    I suggest you to have a webtemplate against the query and create SAP BW Report iVew in the portal.
    Iin  WAD tool you suppress standard options/ have new options by adding javascript & Html code.
    Ram

  • Suppress zero rows in the query output.

    Dear Experts,
    We executed a query. In the output the values are displayed based on a hierarchy on gl account.
    But in the output some rows dont have any values i.e 0 value. Still those rows are appearing in the report output.I want to
    supress entire row. How to supress the entire row if no value i.e zeros are appearing in the query output.
    Regards,
    Bhadri M.

    go to change mode of query
    in that set the query properties /go to the query property secreen
    in the "Display " tab set the supperssion as "active (all value=0)" and in structure properties select the check box "also use  zero suppression for strucure element"
    i think it will be help ful
    Edited by: Soma Venkateshwarlu on Aug 28, 2009 2:40 PM

Maybe you are looking for

  • Can a Mac Pro (2.66 ghz duel core) be upgradable to support Thunderbolt displays and other devices.

    Can a Mac Pro (2.66 ghz duel core (4cores)) be upgradable to support Thunderbolt displays and other devices. Does this need to be done through the Graphics card expansion or a additional card to be inserted?

  • Writing to file without spaces!

    Hiya :) I am relatively new (ok, very new :) to Java programming. I have had my first attempt at creating a program that can create a new file, and then write to it. The problem is that when I try to write the string "Happy!", It writes " H a p p y !

  • I get an error code 80040154 every time i try to download ITunes. Why and what can i do to stop this?

    Free Download Manager is not properly installed! Please reinstall Free Download Manager.    If you want to download with your browser please remove "npfdm,dll" file in the plugin firectory of your browser. error code 80040154.     HOW DO I DO THIS AN

  • PixelView on Solaris 10

    I try to install pixelview card on Solaris 10. I followed steps described on http://bt848x.sourceforge.net/. I installed driver. Below is the output from modinfo command: bash-3.00# modinfo | grep bt +72 feb61464 35fc - 1 kbtrans (kbtrans (key transl

  • CS2 ACTIVATION, DOWNLOAD LINK NOT WORKING

    I have CS2 that I need to reinstall after a problem with my Mac. The activation server is now unavailable and the links to download the version that does not require activation are not working, they say header length is too large. Please help.