How to get the number of rows returned by a report?

Hi,
I'm developing my first application in APEX and so far everything seems fine, except I can't figure out this very simple thing: I have a report based on a PL/SQL block returning an SQL string. I'd like to have a message (something like "X rows returned") just before the report. The closest thing I could find was "X to Y out of Z" in the pagination styles, but that's not what I want. Also I don't think running the same query to get COUNT() is wise.
Any help would be appreciated.
Thanks,
Konstantin

My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

Similar Messages

  • How to get the number of rows in a report region

    Hi all,
    Is there a way to get the number of rows returned in a report region, without issuing an additional "select count(*) from some_table"?
    I mean something like the substitution string #ROW_NUM# but for the total rows.
    Thanks,
    Pedro.

    http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/ui.htm#CHDDGGEG
    For classic report regions, the region footer supports the following substitution strings:#ROWS_FETCHED# shows the number of rows fetched by the Oracle Application Express reporting engine (the page size). You can use these substitution strings to display customized messages to the user. For example:
    Fetched #ROWS_FETCHED# rows in #TIMING# seconds.
    *#TOTAL_ROWS# displays the total number of rows that satisfy a SQL query used for a report.*
    #FIRST_ROW_FETCHED# and #LAST_ROW_FETCHED# display the range of rows displayed. For example:
    Row(s) #FIRST_ROW_FETCHED# through #LAST_ROW_FETCHED# of #ROWS_FETCHED# displayed>
    Ta,
    Trent

  • Getting the number of rows returned from ResultSet

    Hi,
    Does anyone know a method to get the number of rows returned with a query using the Resultset class?
    Thanks.

    Hi 281080,
    If your database and JDBC driver support it, in order to use the solution that da-alexj has suggested, you need to create a 'scrollable' "ResultSet" -- the javadoc for method "createStatement()" (in class "java.sql.Connection") has more details.
    However, I have found with Oracle 8.1.7.4 database and Oracle (thin) JDBC driver, that part of their implementation of the "last()" method (in class "java.sql.ResultSet") is to actually iterate through the entire "ResultSet" in order to reach the last row. If your "ResultSet" is very large (I tested it with a 100,000 row "ResultSet"), this will take a long time.
    Just wanted to make you aware of that.
    Of-course, this may be irrelevant to you since I didn't see any mention in your post of what database and JDBC driver you are using.
    Hope this has helped you, anyway.
    Good Luck,
    Avi.

  • How to Customize the Message "No Row Returned" from a Report

    Hi,
    I've been trying to customize the Message "No Row Returned" from a Report.
    First i followed the instructions in Note:183131.1 -
    How to Customize the Message "No Row Returned" from a Report
    But of course the OWA_UTIL.REDIRECT_URL in this solution did not work (in a portlet) and i found the metalink document 228620.1 which described how to fix it.
    So i followed the "fix" in the document above and now my output is,..
    "Portlet 38,70711 responded with content-type text/plain when the client was requesting content-type text/html"
    So i search in Metalink for the above and come up with,...
    Bug 3548276 PORTLET X,Y RESPONDED WITH CONTENT-TYPE TEXT/PLAIN INSTEAD OF TEXT/HTML
    And i've read it and read it and read it and read it and can't make heads or tails of what it's saying.
    Every "solution" seems to cause another problem that i have to fix. And all i want to do is customize the Message "No Row Returned" from a Report. Please,...does anyone know how to do this?

    My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

  • How to get the number of rows in a repeating frame ?

    Hi all,
    When I launch a report from forms then sometimes there are data in the report and sometimes there are no data. And the problem is that when there are no data then the frame containing the repeating frame is still displaying and a blank page displays on the report.
    So I want to get the number of rows from the repeating frame so that I can code a format trigger on the frame to display or not the enclosing frame depending on the existence of data from the repeating frame.
    Thank you very much indeed.

    Dear Friend,
    You can achieve this. Define a summary column (say cnt). Select summary type as "COUNT". select any one of columns that are getting displayed in your repeating frame as summary column and provide "reset at" group name (or set this to report if you are defining this field at report level) . This "cnt" variable will contain how many records that will be fetched for your repeating frame (i.e. Group of Repeating frame). You can use this "CNT" variable in your format trigger.
    In this case there is no need to write before report trigger or anything.
    Regards,
    Manish Trivedi

  • How to get the number of rows in a DB-Cursor

    When i open a database cursor i do not know how much rows are stored in the cursor. To solve this problem i have to send a 'select count(1) ...' to get the number of rows before i set up the cursor. I think that this is not very clever and could possibly cause performance problems. But i need the num of rows to show the percentage of processed rows. Is there any other way to get the num of rows? May be by checking the cursor directly?
    Please help!
    Thanx a lot

    In order to find out how may rows are going to be processed, oracle has to visit every row. So with a cursor, there is no property that will accurately reflect the number of rows until you get to the last one. That said, you could use
    select count(*) over() as row_count, <rest of your columns> FROM <your table>
    which will give you the total row count agaist each row in the result set. There are performance penalties involved but they will be less than issuing the query twice, once to get the count and once to get the rows.
    Have a look on asktom for some very usefull info about all this.
    HTH

  • How to get the number of rows in a ResultSet

    Hello,
    I'm an intern and I'm trying to get the number of rows from result set in oracle using rs.last() and rs.beforeFirst() methods
    but I got an error. Could Below is my sample code:
    import java.sql.*;
    public class SarueckConnect {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet re = null;
    String[] ParamArray;
    ParamArray = new String[24];
    //Properties logon;
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
    con = DriverManager.getConnection
    ("jdbc:oracle:thin:@258.8.159.215:1521:test_DB","data","data"); //making the connection DB.
    stmt = con.createStatement ();// Sending a query string to the database
    //stmt.executeUpdate("UPDATE test_table set steuk = 6 WHERE steuk = 5");
    ResultSet rs = stmt.executeQuery("SELECT mandt,kokrs,werks,arbpl,aufnr,vornr,ile01,"+
    "lsa01,ism01,ile02,lsa02,ism02,ile03,lsa03,ism03,ile04,lsa04,ism04,steuk,matnr,budat,"+
    "kostl,pernr,rueckid FROM test_table where steuk =6");
    //Print the result out.
    rs.last(); //This is the line which gives an error.
    int rows = rs.getRow();
    rs.beforeFirst();// I presume this is wrong to.
    ParamArray = new String[24*rows];
    int counter=0;
    while (rs.next()) {
    for (int i = 1; i <= 24; i++){
    ParamArray[i-1+(counter*24)] = rs.getString(i);
    System.out.print(rs.getString(i) + '\t');
    System.out.println();
    counter++;
    } catch(Exception e) {
    e.printStackTrace();
    } finally {
    try
    if(stmt != null) stmt.close();
    if(con != null) con.close();
    } catch (Exception exception) {
    exception.printStackTrace();
    TryBapi sap = new TryBapi(ParamArray);
    }When I run the code I do have the following ERROR Message:
    java.sql.SQLException: Invalid operation for forward only resultset : last
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.driver.BaseResultSet.last(BaseResultSet.java:91)
    at SarueckConnect.main(SarueckConnect.java:28)Please could any body Help me out here to figure out how to correct this?
    Any Help would be highly apprecited.

    make your result set scrollable...Not such a good idea. With Oracle, the JDBC driver will read and cache all the ResultSet in memory (with other DBMSs/drivers the behavior will probably be different, but you will still have some unnecessary overhead).
    You can do the caching yourself if you think it's worth it. If the piece of code you posted is why you need this for, then use a List or Vector and you won't need to know the size upfront.
    Alin,
    The jTDS Project.

  • How to get the number of rows written to the header of the spool file.

    Hi
    I need to create a header line for the spool file .
    the header line should include fixed length values .
    The header should include the number of records found in the table with a maximum begin date (begin_date is the column of the table)
    To get the header in the spool file , i wrote a select query has :-
    --SPOOL 'C:\Documents and Settings\abc\Desktop\output.TXT'
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school
    group by sysdate;
    SPOOL OFF
    which gets me all the rows in the table , but i only want the rows with the latest school_begin_date .
    how can i achieve that ...
    I know that a subquery should be written in the from clause to get the number of rows found with a maximum school_begin_date.
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school where
    select rownum from dad.school
    where school_begin_date = max(school_begin_date) ;
    the error i get is
    ORA-00934: group function is not allowed here
    I NEED HELP ..IN GETTING THE ROWNUM JUST FOR THE LATEST BEGIN_DATE ?
    PLS HELP ME IN WRITING THE QUERY .
    THANKS IN ADVANCE .

    Try this:
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000')||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) || rpad(' ',76,' ')
      from dad.school
    where school_begin_date = (select max(school_begin_date)
                                  from dad.school);

  • Need to know how to limit the number of rows returned on Oracle

    MS SQL Server has a command called 'set row count'.
    We are trying to find similar one on Oracle.
    What we are trying to do is that instead of using rownum in the query statement, we would like to find way to limit the number of rows returned. I understand that we can use JDBC resultSet object, but that's not what we want.
    I know Oracle has one called arraysize, but this would not limit the number of rows returned either.
    Pease help.
    Thanks

    I understand that we can use JDBC resultSet object, but that's not what we want.I'm not sure which feature of ResultSet you use and which not.
    But if this question has anything to do with JDBC (that's the forum where you put it), I'd recommend to use Statement.setMaxRows(). This will limit the count of rows which your statement will fetch into it's ResultSet.

  • Get the number of rows returned by a dataProvider

    hi
    I am using a [Bindable] variable that I am setting and using
    as a DataProvider (coming from a web service) for a DataGrid within
    my Flex 2 application.
    is there a way of knowing the amount of rows that the
    dataProvider is returning???
    as I want to do a calculation to set the height of the
    dataGrid depending on the amount of rows being returned by the
    dataGrid!
    any suggestions...?
    Thanks,
    Jon.

    that only seems to count the default number of rows (height)
    of the datagrid..... i.e. 7.
    I need to know the number of rows being returned from the
    dataProvider - i.e. the number of rows coming through the
    webService from the database etc.....
    Thanks,
    Jon.

  • How to get total number of rows return by query

    hi all
    i am using forms 6i with oracle 10G in windows environment....
    i have a tabular form now i want to know that how many rows return by the query...like when user click on enter query and then give any search criteria and then execute query..it displays the records but i want to count the records that how many rows are return.............
    hope you understant what i mean
    Thanks in advance
    Regards

    U can use
    "Select count(*) from <table> where <condition>"
    <condition> is the where clause being used during "Execute Query"
    this will give u the no of records in query.
    And second option is to take a summary column. whose function is set "COUNT" and
    "Summarized item" should contain a column that will never be blank. After execute query this column will give u no of records in block.
    Regards....

  • How to get the number of rows in a HTML table in some other page

    Hi,
    I am incrementing HTML table rows on button click and saving number of rows in a javascript variable. But on submitting that page I need that number of row value in the following page
    example:
    HTML table is in the page first.jsp
    and the javascript variable having the current row number is row_number
    on submitting it goes to second.jsp page. There i need that row_number value.
    Can anyone help me to solve this?
    regards,
    carry

    function buttonClick()
    var table = profileTable;
    var lnRow = table.rows.length;
    var insertedRow = table.insertRow(parseFloat(lnRow));
    var cell1 = insertedRow.insertCell();
    cell1.innerHTML ="<tr><td><Input type=\"hidden\" >>>name=\"rowNum\" value="+cnt"+></td></tr>";
    document.profileform.submit;
    on submit it goes to the second page, but the value i got using >>>System.out.println("row number from text >>>box"+request.getParameter("rowNum")); is null. What is wrong with >>>my coding. Can anyone solve this.HI carry
    Check the value of bold data
    function buttonClick()
    var table = profileTable;
    var lnRow = table.rows.length;
    var insertedRow = table.insertRow(parseFloat(lnRow));var cnt=inRow
    var cell1 = insertedRow.insertCell();
    cell1.innerHTML ="<tr><td><Input type=\"hidden\" >>>name=\"rowNum\" value="+cnt+"></td></tr>";
    document.profileform.submit;
    }try with it

  • How to get the number of hits ("returned rows") in read table statement

    Hi Experts
    I have the statement shown below, which seems not to work as I would like it to. My problem is that I would like to do two different things depending on weather or not a read table statement results in 0 hits or 1 (or more) hits.
        READ TABLE g_ship_item
            WITH KEY
         l_ztknum = DATA_PACKAGE-/bic/ztknum
         BINARY SEARCH.
          IF sy-subrc is initial.
          no hits found
            DATA_PACKAGE-/BIC/ZSTAGEERR = 1.
          ELSE.
          hits where found and we will do something else...
            DATA_PACKAGE-/BIC/ZSTAGEERR = 0.
    Hope someone can help me out of my problem...
    Thanks in advance, regards
    Torben

    Hi,
    As you are using READ statement with Binary search, check whether the internal table g_ship_item is sorted with field /bic/ztknum or not. If it is not sorted then the result of this READ statement is not correct.
    Below is the correct code.
    sort  g_ship_item by /bic/ztknum.
    READ table g_ship_item with key g_ship_item = xxx.
    Thanks,
    Satya

  • Restrict number of rows returned in a report

    Hi All
    Does anyone know how to restrict the number of rows returned in a report eg. I want to do a couple of reports based on opportunities/products and return only the top 5 or 10???
    Thanks
    Gail

    Sorry just answered my own question by using the 'is in top' colum filter!

  • How can I limit the number of rows returned by a select stat

    How can I limit the number of rows returned by a select
    statement. I have a query where I return the number of stores
    that are located in a given area.. I only want to return the
    first twenty-five stores. In some instances there may be over
    200 stores in a given location.
    I know is SQL 7 that I can set the pagesize to be 25....
    Anything similiar in Oracle 8i?
    null

    Debbie (guest) wrote:
    : Chad Nale (guest) wrote:
    : : How can I limit the number of rows returned by a select
    : : statement. I have a query where I return the number of
    : stores
    : : that are located in a given area.. I only want to return the
    : : first twenty-five stores. In some instances there may be
    : over
    : : 200 stores in a given location.
    : : I know is SQL 7 that I can set the pagesize to be 25....
    : : Anything similiar in Oracle 8i?
    : If you are in Sql*Plus, you could add the statement
    : WHERE rownum <= 25
    : Used together with an appropriate ORDER BY you
    : could get the first 25 stores.
    Watch out. ROWNUM is run before ORDER BY so this would only
    order the 25 selected
    null

Maybe you are looking for

  • Datapump : How to append data in an existing table

    Hello Everyone, We are new to Datapump. We try to extract data from one user/schema and to append it into another user/schema. First we tried Tt use the parameter table_exists_action=append during the importation but we receive this error (but the ro

  • ABAP Mapping for Error handling in Proxy to JDBC

    Hi All, I am working on a proxy to jdbc scenario in which we have to throw validation errors to NWPM(Net Weaver Process Monitor Tool) I am following the below steps, step 1 - In message mapping a UDF is created to catch errors and store them in a var

  • Error in repository creation in OWB

    Hi Experts I m tying to create one repository REP_OWNER at my Onsite server. But at the time of creation i m getting the below error. Please suggest me the solution to overcome this. Error : java.sql.sqlexception. lo exception. coneection reset Thank

  • My system preferences is not working/ responding. Please help.

    System Preferences is inactive. On the dock the Icon has a question mark on it. I tried other solutions on  here, but nothing has work. Please help. Thank you Mac OS X 10.6.8

  • Slight hang when loading Firefox 27.0.1 on Windows 8.1 Pro

    I just upgraded from Windows 8 Pro to 8.1 and installed Firefox 27.0.1. Now Firefox has a fairly substantial delay when loading. When I say "fairly substantial" I mean about 6 seconds, every other program including IE is instantaneous and even Photos