Hello,
see my answer below.
> -----Original Message-----
> From: Blas Rodriguez Somoza [mailto:[EMAIL PROTECTED]]
> Sent: Montag, 28. Januar 2002 12:49
> To: [EMAIL PROTECTED]
> Subject: [SAP DB]Fw: Updatable/Scrollable ResultSet>
>
> Hello.
> I'm trying to use updatable ResultSet and I had two problems.
> I'm working with JDBC version 7.3.0.21a.
> This is the description step by step:
> 1.- I create an Statement with
> stmt =
> database.Conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE
> , java.sql.ResultSet.CONCUR_UPDATABLE);
> or
> stmt =
> database.Conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_I
> NSENSITIVE
> , java.sql.ResultSet.CONCUR_UPDATABLE);
> 2.- I execute the query and apparently everything goes right
> (the query includes all the fields of one table)
> 3.- When I use .getType() it throws an exception.
Sorry, we forgot to implement this api-method. It will always throw a
NotImplementedException. I correct this in the next version of the
JDBC-driver.
> 4.- getConcurrency() works OK.
> 4.- I take all the rows in the table to fill a JTable with rs.next().
> 5.- I move to a row with .absolute() and get the value of a
> column with getValueAt(). The value is the correct one.
> 6.- When I execute updateString() on the same value I get the
> following Exception
> com.sap.dbtech.jdbc.exceptions.InternalJDBCError:
> [prepareHelper]SAP DBTech SQL: [-9005] System error: BD Illegal key
> at
> com.sap.dbtech.jdbc.UpdatableResultSetSapDB.prepareHelper(Upda
> tableResultSetSapDB.java:312)
> at
> com.sap.dbtech.jdbc.UpdatableResultSetSapDB.prepareUpdate(Upda
> tableResultSetSapDB.java:339)
> at
> com.sap.dbtech.jdbc.UpdatableResultSetSapDB.findUpdateColumn(U
> pdatableResultSetSapDB.java:163)
> at
> com.sap.dbtech.jdbc.UpdatableResultSetSapDB.updateString(Updat
> ableResultSetSapDB.java:1048)
> at
> containers.SQLExecuteTMListener.tableChanged(SQLExecuteTMListe
> ner.java:36)
We needed some days to reproduce this error and analyze it. Thank you very
much for delivering the tracefiles and your testprogram (send outside of
this mailing list). Unfortunately this is a bug in the database kernel. The
JDBC-updatable Resultset does not work, if you update a table_1 and another
table_2 has a foreign key relationship on this table_1. This bug will be
fixed in the next version of SAPDB.
For the moment you have the following possibilities:
1. Waiting for a new version of SAPDB kernel (maybe in 4-8 weeks available).
2. Don`t use a foreign key relationship for tables which you use in a
JDBC-updatable Resultset.
3. Simulate the behaviour of an updatable resultsets:
java.sql.Statement Stmt1, Stmt2;
String sqlCommand = "SELECT ... FROM TABLE";
if (resultSetConcurrency == java.sql.ResultSet.CONCUR_UPDATABLE) {
sqlCommand += " FOR UPDATE OF ";
}
else if (resultSetType == java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE) {
sqlCommand += " FOR REUSE";
}
java.sql.ResultSet rs = Stmt1.executeQuery(sqlCommand);
rs.setFetchSize(1); //Note: it only works if fetchsize is set to 1
/*fetch some results*/
while (rs.next()){
//whatever
}
rs.absolute(2);
/*update the current record*/
Stmt2.executeUpdate("UPDATE TABLE SET ... WHERE CURRENT OF
\""+rs.getCursorName()+"\"");
rs.close();
stmt.close();
With kind regards and many thanks for your help,
Marco Paskamp
----------------------------------------------
Marco PASKAMP
SAP DB, SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general