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.
Similar Messages
-
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 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,
KonstantinMy 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 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 -
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?
nullDebbie (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 -
How can I get the number of rows in my sql result, without a loop?
Hello,
I've a problem, I would like to get the number of rows in my sql result without make a loop like :
while (rs.next()){
int number = rs.getRow();
Is there any method to do this, on the first element?
Thx, STeFIf you want to count how many rows are in result set, I dont think you can, but you could always run a count statement for that sql
say your sql is
select field1, field2, field3
from table1, table2
where field4=field5 ......
then you can count the rows this statement returns by
select count(*) from
(say your sql is
select field1, field2, field3
from table1, table2
where field4=field5 ......)
This way you will get the count for just that sql -
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 -
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 lotIn 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); -
Can I limit the number of rows returned on a Select?
Can I limit the number of rows returned on a Select statement? I would be using JDBC in a Java program.
Use Java prepared statements with the equivalent of this SQL*plus script:
VARIABLE n number
EXEC :n := 3;
SELECT rownum FROM all_objects WHERE rownum <= :n;
ROWNUM
1
2
3
EXEC :n := 5;
SELECT rownum FROM all_objects WHERE rownum <= :n;
ROWNUM
1
2
3
4
5 -
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.
ThanksI 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 affected by update statement
Hi
I'm working on an application that uses OCI as interface against an Oracle database.
I'm trying to find out how i can get the number of rows affected by a query executed with OCIStmtExecute. it is not a select query.
Best regards,
Benny TordrupIf I run a bulk UPDATE query using OCIBindArrayOfStruct, is there a way I can tell which+ rows successfully updated?
I have a file of records of which 75% of PKs are already in the table and will be updated, the other 25% aren't and should be inserted later. I want to attempt an UPDATE statement using OCIBindArrayOfStruct to execute in bulk and then check which entries in my bulk array successfully updated. If an array entry isn't successfully updated then I will assume it should be inserted and will store it for a Direct Path load later.
Many thanks for any advice you can give as I've been trawling through the docs trying to find a solution for ages now. -
Output the number of rows returned in a query
How do I find out the number of rows that are returned in a query?
COUNT function I guess can only be used when there is only one table involved. How do I do it for multi table query like JOIN?
For example
SELECT emp.first_name, emp.last_name, jobs.age FROM employees emp, jobs
WHERE emp.employee_id=jobs.employee_idHi,
You can get the num of rows info
select count(*) from (SELECT emp.first_name, emp.last_name, jobs.age FROM employees emp, jobs
WHERE emp.employee_id=jobs.employee_id) ;
regards
Jafar
http://www.oracledbarea.blogspot.com
Maybe you are looking for
-
How can I execute a java program from a Servlet?
Thank You [email protected]
-
Copying member("aTextMemb").image into a rect in an image that uses alpha
Hi all. I'm currently developping a strategy game with Director, and one of the things I've run into is that i want to update the number of units I have in a panel (on initial game setup) via 1) updating a text member that holds the number of units l
-
Best way to add numbers or layout multiple pages
I have a ticket that needs to be numbered. It is small enough to go 5 up on a sheet that is 8.5 x 11. Each ticket needs to be numbered. I can make a master page and add all of the numbers that way and then make a pdf. What is the best way to get the
-
Design Template to change ONLY text boxes
I am afraid of the Design Template option because all I need to do is globally change ALL the text in my project to be ARIAL 11.... while it seems that Design Template would do this, there are all these other captions, buttons, etc. on there and I wa
-
Output of show int po1 etherchannel doesnt show load?
Hi, I have a set of 3750 switches which are stacked into 2 sets of 3. I have creted a port channel on each stack that connects to the other stack, as it is cross stack I have used channel-mode on. when i type the follwoing command, some values show a