Re: how to number of rows in resultset without % ...

2001-11-19 Thread Dmitri Colebatch

A resultset has a cursor, and depending on how big it is, you might be
better off having a separate query to detemine the number of rows (using
SELECT COUNT(index) FROM table WHERE same_where_clause).

cheers
dim

On Mon, 19 Nov 2001, Dalibor Kezele wrote:

 From: Bradley M. Handy [EMAIL PROTECTED]
 To: 'Struts Users Mailing List' [EMAIL PROTECTED]
 
  Try this.
  
  ResultSet resultSet = execute query here to return a result set
  int numRows = 0;
  if(resultSet.last()) {
  numRows = resultSet.getRow();  // return the row id.
  }
  One thing to note is if your ResultSet is not setup to for
  bi-directional reading, you will lose the use of your ResultSet doing
  this.
  
 That's okay, but I would like to do this without using java.
 
 Something like:
 html:select property=segment multiple=true size=sql:getSize/
 
 TIA,
 
 
 
 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]
 
 


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: how to number of rows in resultset without % ...

2001-11-16 Thread Bradley M. Handy

Try this.

ResultSet resultSet = execute query here to return a result set
int numRows = 0;
if(resultSet.last()) {
numRows = resultSet.getRow();  // return the row id.
}

One thing to note is if your ResultSet is not setup to for
bi-directional reading, you will lose the use of your ResultSet doing
this.

Bradley M. Handy
Programmer/Analyst
Spring Arbor University
--www.arbor.edu
--mailto:[EMAIL PROTECTED]
 

-Original Message-
From: Richard Yee [mailto:[EMAIL PROTECTED]] 
Sent: Friday, November 16, 2001 2:24 PM
To: Struts Users Mailing List
Subject: Re: how to number of rows in resultset without % ...

TIA,

Try SELECT COUNT() FROM mytable

That should return the # of records returned.

Regards,

Richard


At 01:46 PM 11/16/2001 +0100, you wrote:
Multiple selectbox. It has size attribute which has to be set in order
to
show all rows in database.
I'm using % ... code to get the number of rows in resultSet since I
have
to know it before I take
data and display it in table. Could I get this size at least without
%
..?

sql:preparedStatement ...
 sql:query
  SELECT * FROM MYTABLE
 /sql:query
 % int i = 0; %
 sql:resultSet id=rsAction loop=true
  % i++; %
 /sql:resultSet
 % String size =  + i; %
 sql:query
  SELECT * FROM MYTABLE
 /sql:query
 html:select property=segment multiple=true size=%=size
%
  sql:resultSet id=rsAction loop=true
   % String id = rsAction.getString(1), value =
rsAction.getString(2); %
   html:option value=%=id %%=value%/html:option
  /sql:resultSet
 /html:select
/sql:preparedStatement

TIA,



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]