Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2003

Tip: Looking for answers? Try searching our database.

Oracle 8i Cursors via JDBC

Thread view: 
David - 30 Oct 2003 02:57 GMT
Does anybody have samples of how to use JDBC calls to work with a
cursor on Oracle 8i?  Can it even be done?

I'd like to be able to do something like:

String sql = "DECLARE CURSOR my_cursor FOR SELECT name,id FROM
name_tbl";
statement.execute(sql);  (executeQuery?  executeUpdate?)
...
while(...)
{
 String query = "FOR 100 FETCH my_cursor";
 ResultSet rs = statement.executeQuery(query);
 // process up to 100 rows in another loop and then fetch 100 more
 // how do I know when the cursor has run out of rows versus just
 // the ResultSet running out of its rows (do I just try again as
long
 // as I get 100 rows in ResultSet or is there something else that
tells me?
}

Thanks,
David
Andy Flowers - 04 Nov 2003 22:25 GMT
Is it not simpler to just do the following

// obtain connection and then the statement...

String sql = "SELECT name,id FROM name_tbl";
ResultSet rs = statement.executeQuery(sql);
if( rs.next())
{
// we appear to have some results

boolean finished = false;
while(!finished)
{
  // process in 100 row chunks
  for( int i = 0; i < 100; i++ )
  {
     // do something

     if( !rs.next())
     {
       // all finished - no more data
       finished = true;
     }
  }
}
}

> Does anybody have samples of how to use JDBC calls to work with a
> cursor on Oracle 8i?  Can it even be done?
[quoted text clipped - 19 lines]
> Thanks,
> David


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.