Home » Developer & Programmer » JDeveloper, Java & XML » retrieving files for paging
retrieving files for paging [message #137442] Thu, 15 September 2005 04:37 Go to next message
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 Go to previous messageGo to next message
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 #137595 is a reply to message #137442] Thu, 15 September 2005 11:28 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Use the logic from here.
Re: retrieving files for paging [message #137828 is a reply to message #137595] Sat, 17 September 2005 04:37 Go to previous messageGo to next message
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 Go to previous message
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!
Previous Topic: oracle/jdev
Next Topic: I can't control my AppModule
Goto Forum:
  


Current Time: Sat Apr 20 08:58:20 CDT 2024