Is it possible to count the rows returned from a query?

When using JDBC is there anyway of finding out the number of
rows returned from a query before actually getting each row?
In Forms 4.5 you can use the count_query function, does anyone
know of an equivalent function or work around in JDBC and/or

Pasi Hmlinen (guest) wrote:
: Try
: SELECT COUNT(*) FROM the_table WHERE <conditions>;
: Hope this helps,
: Pasi
Thanks for the advice, I'm currently using SELECT COUNT(*) but
I'm looking for a more efficient way of doing it. If I SELECT
COUNT each time then I have to prepare and execute a SQL
statement each time. What I want to do it execute a single SQL
statement to return my results and somehow find out the number
of rows in the resultset without having to go back to the

Similar Messages

  • Req. the script for sending the rows returned by a query to my mail id.

    Hi ,
    Can anyone send me the script, for this thing.
    Actually i am working on production side, and i am executing the query which will return the rows of mview name which are not getting refreshed with the specified frequency. so i want those rows returned by query to be send to my mail id.
    Thanks a lot..
    With Regards

    Please review the following link;

  • How to capture all the rows returned from a sql select query in CPO

      I am executing an sql select query which returns multiple rows. I need to capture the values of each row to specific variables. How do I proceed.

    The select activities  ("Select from Oracle," Select from SQL Server," etc.) against database already return tables.  Use one of the database adapters to do your select, and it will already be in a table form.  Just put your query in the select and identify the columns in your result table. The online help or the database adapter guides in the product documentation can help.

  • Number of rows returned in a query

    Is there a way to get the number of rows returned from a query without itterating through the itterator?

    Because rows are not all returned until you start interating.
    Some times I have seen people do a count query before the normal query, this helps out if you need a count to set things up.

  • XMLAttribute unable to handle multiple values returning from a query

    Hi Guys,
    I have to design the format of the data returning from a query in XML. For this i have used xmlelement and xmlattribute
    the query goes like this
    SELECT '<?xml version="1.0" ?>'||' '||XMLELEMENT("imageData",
    XMLATTRIBUTES(LI.GROUPNO as "imageName", 'PNG'as "imageType", '2.0' as "version", '' as "xmlns"),
    XMLATTRIBUTES('roundedRectangle' as "shape"),
    here he logic is the one groupno from pfealigil and the corresponding pnc_keyno that are related to groupno are fetched here. but here since multiple pnc_keyno are returning xmlattributes is unable to handle. I want to design the xml in this format
    <?xml version="1.0" ?>
    <imageData imageName="ISDH0001104"
    imageType="PNG" version="2.0" xmlns="">
    <callouts shape="roundedRectangle">
    <callout label="182">
    <point x="289" y="68"/>
    <callout label="247"<point x="430" y="83"/>
    <callout label="122"><point x="546" y="331"/>
    <callout label="249"><point x="402" y="429"/>
    <callout label="248"><point x="392" y="463"/>
    <callout label="182"><point x="228" y="416"/>
    <callout label="1"><point x="364" y="737"/>
    <callout label="14"><point x="494" y="980"/>
    <callout label="168"><point x="671" y="910"/>
    <callout label="15"><point x="779" y="848"/>
    <callout label="1"><point x="805" y="343"/>
    like here one image name all those pnc_keyno that are valid should come in this way as above. Please let me know if anything is unclear to you

    apexStarter wrote:
    Data model goes like thisYou mentioned two tables in your first post, but I guess it's just a matter of joining them to get the above resultset?
    In this case you can do it like this :
    SQL> WITH sample_data AS (
      2    SELECT '91-921' groupno, '1125AE' pnc_keyno, 000000127 coordinatesx1, 000000730 coordinatesy1 FROM dual UNION ALL
      3    SELECT '91-921', '18642F', 000000513, 000000891 FROM dual UNION ALL
      4    SELECT '91-921', '18643D', 000000620, 000000844 FROM dual UNION ALL
      5    SELECT '91-921', '18649E', 000000561, 000000688 FROM dual UNION ALL
      6    SELECT '91-921', '18668B', 000000620, 000000864 FROM dual UNION ALL
      7    SELECT '91-921', '92101A', 000000587, 000000591 FROM dual UNION ALL
      8    SELECT '91-921', '92102A', 000000587, 000000571 FROM dual UNION ALL
      9    SELECT '91-924', '1243BD', 000000617, 000000889 FROM dual
    10  )
    11  SELECT XMLRoot(
    12           XMLElement("imageData",
    13             XMLAttributes(
    14               groupno as "imageName"
    15             , 'PNG'as "imageType"
    16             , '2.0' as "version"
    17             , '' as "xmlns"
    18             )
    19           , XMLElement("callouts",
    20               XMLAttributes('roundedRectangle' as "shape")
    21             , XMLAgg(
    22                 XMLElement("callout",
    23                   XMLAttributes(pnc_keyno as "label")
    24                 , XMLElement("point",
    25                     XMLAttributes(
    26                       coordinatesx1 as "x"
    27                     , coordinatesy1 as "y"
    28                     )
    29                   )
    30                 )
    31               )
    32             )
    33           )
    34         , version '1.0'
    35         )
    36  FROM sample_data
    37  GROUP BY groupno
    38  ;
    <?xml version="1.0"?>
    <imageData imageName="91-921" imageType="PNG" version="2.0" xmlns="">
      <callouts shape="roundedRectangle">
        <callout label="1125AE">
          <point x="127" y="730"/>
        <callout label="92102A">
          <point x="587" y="571"/>
        <callout label="92101A">
          <point x="587" y="591"/>
        <callout label="18668B">
          <point x="620" y="864"/>
        <callout label="18649E">
          <point x="561" y="688"/>
        <callout label="18643D">
          <point x="620" y="844"/>
        <callout label="18642F">
          <point x="513" y="891"/>
    <?xml version="1.0"?>
    <imageData imageName="91-924" imageType="PNG" version="2.0" xmlns="">
      <callouts shape="roundedRectangle">
        <callout label="1243BD">
          <point x="617" y="889"/>

  • Count the rows which are selected ?

    Hi Experts,
    I need help.My requirement is:
    I am having a table which can be multiple selected. But there are two buttons attached to it.Edit and Delete.For Delete I want the Multiple Selection not for EDit.So, If i will click the Edit after multiple selection of the rows.How i can give pop-up that multiple edit is not possible?Means I want to count the rows which are selected how to do that?
    Please guide me.
    Urgent need

    Hi Nutan,
    Marcel is right about backend. However I might have an idea once I am developing a quiet similar solution. I would like to ask you to explain with more detail. It seems you have two requirements in one question.

  • Counting the rows

    I've a datamodel with BI Query. I want count the rows like a rownum function. How can I do this?
    Thanks R.
    Edited by: user12003776 on Jan 26, 2012 5:02 PM

    Do you want to get a count of rows in the query or do you want to find the count in the template? Rownum function returns the rows' position.
    If you want to find the count of rows within the template for some conditionally formatting, then you could use something similar to this:
    <?count(/XXTA_SHIP_LABEL/LIST_G_CUSTOMER/G_CUSTOMER)?> -- change the path to the field in your dataset
    Can you explain a bit more as to what you are trying to do?

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

    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,...
    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.

  • Is it possible to switch the rows and columns?

    Is it possible to switch the rows and columns of a table? The reason I ask is that it would be easier for me to input the data with the number at the top of a column and the fields going down. But it would be easier to read the data with the number on the left and the fields going to the right. Is it possible to switch a table in this way?

    mahongue wrote:
    Is it possible to switch the rows and columns of a table? The reason I ask is
    that it would be easier for me to input the data with the number at the top
    of a column and the fields going down. But it would be easier to read the
    data with the number on the left and the fields going to the right. Is it
    possible to switch a table in this way?
    It sounds to me as though you wish to transpose a table so that the original is changed from rows to columns and from columns to rows, as in the following:
    Table 1
        A   B   C
    1   o   p   q
    2   r   s   t
    3   u   v   w
    Table 2
        A   B   C
    1   o   r   u
    2   p   s   v
    3   q   t   w
    You are right - it would be nice to have a menu item to magically transpose a selected block of cells. But there isn't one. So...
    One way to solve this is to use the index() and transpose() functions to accomplish row and column cell transposition. If you are going to use a 1:1 cell correspondence and change the header columns and rows also, you can use this:
       =INDEX(TRANSPOSE(Table # :: <range>),ROW(),COLUMN())
    where Table # and <range> is substituted as in the following fashion:
       =INDEX(TRANSPOSE(Table 1 :: $A$1:$C$3),ROW(),COLUMN())
    Create a second table. Copy the modified formula above with the appropriate substitutions, select the range you wish to have your transposition inserted into (must match the transposed cell dimensions of the original range), paste the forumula and voila! the cells will be transposed.
    o The target table must match the swapped cell length and width dimension. For example, if the original data range is 6 columns wide by 4 rows deep, then the corresponding table or range to hold the transposition must be 4 columns wide by 6 rows deep.
    o If your transposed data block is to be offset from the origin of the new table, then you will need to include a subtractive offset into your cell formula, since in the transpose() function the data in the master data range is referenced from its position with the master range, not its cell position in the table. Such an offset is necessary because this example formula uses the target row and column numbers to arrive at indexed positions.
    For example, if the new data range is to be offset one column to the right and one row below from the target table's origin then you must subtract (-1) from the cell and from the column references in the formula:
      =INDEX(TRANSPOSE(Table 3 :: $B$2:$D$4),ROW()-1,COLUMN()-1)
    If someone has a better solution I'd be glad to hear of it.

  • Count the rows in a list-component

    How can I count the rows with a value in a list component?
    I thought it would be RowCount but as I figured out that shows the number of shown rows, not the number of rows with a value.

    Try list.dataProvider.length

  • Getting the number of rows returned from ResultSet

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

    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 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,

  • How do you limit the number of rows return from query?

    How do you limit the number of rows return from query? Do all databases support this kind of feature?

    i think the standard is limit
    to get the top 30
    select * from mytable LIMIT 30;returns the first 30 rows
    also if you want a range
    select * from mytable LIMIT 10,30;returns 30 rows starting from 10
    this last one is useful for displaying ranges... something similar happens in these forums when viewing topics and messages

  • Numbering the row returned

    i m having difficulties numbering the rows returned..
    im using rownum function, but it returns me duplicate records even after i distinct it.
    and also it doesnt start from 0
    ANy other way to number the row ?
    EDIT: using oracle function : ROW_NUMBER() also give me the same issue
    Edited by: Sosys on Dec 17, 2008 11:50 AM

    THE query is big..
    it's difficult to post and impossible to test by you..
    just assume this :
    JOHN 111 NY
    JOHN 111 NY
    MARK 112 NJ
    MARK 112 NJ
    CAT 113 WA
    and i want to put number from 1,2,3,4,5 in front..
    1 JOHN 111 NY
    2 JOHN 111 NY
    3 MARK 112 NJ
    4 MARK 112 NJ
    5 CAT 113 WA
    How u do this ?
    i used this :rank() over( order by NAME desc) NO,
    and it will give me:
    1 JOHN 111 NY
    1 JOHN 111 NY
    2 MARK 112 NJ
    2 MARK 112 NJ
    3 CAT 113 WA
    How to make it number from 1 to 5 ?

  • How to get number of rows return in SELECT query

    i'm very new in java, i have a question:
    - How to get number of rows return in SELECT query?
    (i use SQL Server 2000 Driver for JDBC and everything are done, i only want to know problems above)

    make the result set scroll insensitve, do rs.last(), get the row num, and call rs.beforeFirst(), then you can process the result set like you currently do.
             String sql = "select * from testing";
             PreparedStatement ps =
             ResultSet rs = ps.executeQuery();
             System.out.println("Row count = " + rs.getRow());
    NOTE: Ugly, but does the trick.

  • Inserting static text in between rows returned from a pivot table

    Is there a way to type static text (eg. “Note that the data for Land has an accuracy of 98%”) in between rows returned from the dataset in the rtf template. The alternative would be to break the BI analysis report (which is the source of the template data) into 2 parts and then insert each part into the template one below the other with the text typed in between.

    Oracle support has confirmed that this requirement is not possible to implement

Maybe you are looking for

  • Data error while loading data using SQLLDR

    Hi Gurus, Kindly let em know the possible reasons for getting the below error returned by SQLLDR after loading data: x no of rows not loaded due to data errors in SQLLDR Could it be due to issues in control file?

  • Sample XSLT code to Display the Current date and time

    Hi all, Please Let me know code to display the system date in my target in xslt mapping. I am trying fn:current-datetime() function for the same.but could not get how to use it .Is it  function right  function.If so please send me the examples on the

  • Error while mapping UICust & View.......

    Hello all, Need ur urgent help!!

  • How to set FTP parameters through Module Processor?

    Hi We read parameters set in the communication channel of an adapter through method getSupplementalData("module.parameters") of I have following question regarding reading/writing configuration data, set in commun

  • Upgrading 9i Data Guard configuration to 10gR2

    I have a question on upgrading to 10gR2 with respect to Data Guard. We currently have physical standby databases for our production databases in 9i ( We are about to upgrade to 10g within the next quarter. At this time we are not using RMAN