Oracle 8i Cursors via JDBC

From: David (d.wall_at_computer.org)
Date: 10/30/03


Date: 29 Oct 2003 17:57:54 -0800

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



Relevant Pages

  • Re: SelectMethod=cursor and SelectMethod=direct
    ... All the database updates/inserts are done by sql using a prepared statement and then setting the field parameters. ... My only concern is the memory usage as a direct cursor reads the complete resultset into memory. ... If the free MS driver reads everything in immediately, it's just something you would have to deal with, alloting your client enough memory to handle it. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Opinions on approach, please...
    ... To emulate this I plan on using an SQL cursor. ... I COULD do it with a resultset if it wasn't in COBOL or could ... Is it because when you FETCH from a cursor you go back to the ...
    (comp.lang.cobol)
  • Re: while loop in a while loop
    ... Depending on your database vendor and JDBC driver version, ... might not be able to reset the ResultSet cursor. ... The method ResultSet.firstmoves the cursor to the first row in the ...
    (comp.lang.java.programmer)
  • Re: Invalid cursor state - Am I completely stupid?
    ... > Therefore the resultset is on the first row ... Okay, suppose I did move the cursor one row forward. ... I suspect that my resultSet is empty, ...
    (comp.lang.java.programmer)
  • Re: need help using hsqldb
    ... > I think that this is not an hsqldb problem. ... > When you get your ResultSet the cursor isn't set on the first row. ... > The first thing you have to do is to call nexton your ResultSet. ...
    (comp.lang.java.databases)