Hi Andrius, if you had read my post from yesterday (http://listserv.sap.com/pipermail/sapdb.general/2003-January/016829.html) you might had noticed that updates are not always visible in result sets.
So you might never (or somewhere at a place you may not expect) find your inserted row. In any way the first result set does not know that its source has changed (if you, for instance, use an isolation level 'read uncommitted', this might have happened from another session). So the result set complains in the 'refresh row' that it has moved into the 'after last' position, as it does not know that someone did silently changed its source. I'm rather curious if there is any RDBMS that can do such a thing, and executes the example in the way you have expected (there may be some that do the right if you use 'moveToInsertRow' indeed). You can only make an inserted row visible in a predicatable and safe way if you do the statement that did produce the result set again, now with the current values. Regards Alexander Schr�der SAP Labs Berlin > -----Original Message----- > From: Andrius Vilciauskas [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, January 14, 2003 8:48 AM > To: [EMAIL PROTECTED] > Subject: bug in jdbc driver > > > Hello, > > I think I have found a bug in jdbc driver > > Bug description: Sample code stops working after inserting > new row in empty > table > Database sheme: > CREATE TABLE ERP_PURCHASE_REQUESTS_LINES > ( > "ID" Fixed (10,0) DEFAULT SERIAL (1), > "PARENT_ID" Fixed (10,0), > "STOCK_ID" Fixed (10,0), > "QUANTITY" Fixed (10,2), > PRIMARY KEY ("ID") > ) > > Sample code: > > import java.sql.*; > > public class Main { > > public static void main(String[] args) { > try { > Class.forName("com.sap.dbtech.jdbc.DriverSapDB"); > } catch (ClassNotFoundException e) {}; > > Connection c; > try { > c = > DriverManager.getConnection( > "jdbc:sapdb://localhost/ERP_DEV", > "dba", > "dba"); > > Statement s = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, > > ResultSet.CONCUR_UPDATABLE); > ResultSet rs = s.executeQuery("select * from > ERP_PURCHASE_REQUESTS_LINES > where > > parent_id = 7"); > > while (rs.next()) { > System.out.print(rs.getString(1)); > System.out.print(" "); > System.out.println(rs.getString(2)); > } > > System.out.println("END."); > > Statement s2 = c.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, > > ResultSet.CONCUR_UPDATABLE); > s2.executeUpdate("insert into ERP_PURCHASE_REQUESTS_LINES > (parent_id) > values (7)"); > rs.refreshRow(); > rs.last(); > System.out.println("New row "); > System.out.print(rs.getString(1)); > System.out.print(" "); > System.out.println(rs.getString(2)); > > > } catch (SQLException e) { > System.out.println(e.getMessage()); > } > } > > > } > > Error message : Invalid argument value "row" = 0. > > Or question: how to make new row visible in resultset ? > > > > _______________________________________________ > sapdb.general mailing list > [EMAIL PROTECTED] > http://listserv.sap.com/mailman/listinfo/sapdb.general > _______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general
