retrieving files for paging [message #137442] |
Thu, 15 September 2005 04:37 |
shuini
Messages: 5 Registered: August 2005 Location: philippines
|
Junior Member |
|
|
hello.
i hope somebody can answer this for me.
i want to retrieve first 18 records for page 1 and second 18 records for page 2 and so on. record numbers should be in order and should be dynamic, meaning it should move when an entry is deleted.
i tried it using the select top 18 8 from table but it doesn't seem to work.
any help would be greatly appreciated.
|
|
|
Re: retrieving files for paging [message #137479 is a reply to message #137442] |
Thu, 15 September 2005 06:19 |
m4mithilesh
Messages: 3 Registered: September 2005
|
Junior Member |
|
|
Hi,
I think u can try with this logic:
trig_no := to_number(:system.trigger_record);
rec_no := trig_no + 18 ;
last_record;
trig_no := to_number(:system.trigger_record);
if rec_no < trig_no then
go_record (rec_no);
else
go_record (trig_no);
end if;
|
|
|
|
Re: retrieving files for paging [message #137828 is a reply to message #137595] |
Sat, 17 September 2005 04:37 |
shuini
Messages: 5 Registered: August 2005 Location: philippines
|
Junior Member |
|
|
ResultSet rs = stmt.executeQuery("Select * from ( select a.*, rownum rnum from (SELECT * FROM T_LINKMANAGER where and LMFLAG='false' order by lmid asc ) a where rownum <= "+cad+" ) where rnum >= "+crs+");
i used this and what's a for?
|
|
|
Re: retrieving files for paging [message #137858 is a reply to message #137828] |
Sat, 17 September 2005 15:11 |
Art Metzer
Messages: 2480 Registered: December 2002
|
Senior Member |
|
|
"a" is the alias for the in-line view in this query.
P.S. You shouldn't "glue in" your values for cad and crs like that; you should use a PreparedStatement in code that's something like the following (warning, untested code):PreparedStatement prepStmt = cnxn.prepareStatement ("SELECT * FROM ("
+ "SELECT a.*"
+ ", ROWNUM rnum "
+ "FROM (SELECT * "
+ " FROM t_linkmanager "
+ " WHERE lmflag = 'false' "
+ "ORDER BY lmid ASC) a "
+ "WHERE ROWNUM <= ? ) "
+ "WHERE rnum >= ?");
prepStmt.setInt(1,cad);
prepStmt.setInt(2,crs);
ResultSet rs = prepStmt.executeQuery(); Use bind variables!
|
|
|