JCC function deleteRow() returns "Unable to delete row because table name is not available" exception if the resultset contains constant only.

Technote (FAQ)


This document applies only to the following language version(s):

English

Question

Delete a row from resultset in a Java application using IBM JDBC Universal Driver will return "NullPointerException " or "Unable to delete row because table name is not available" exception if the resultset contains constant only.

The error occurs in following scenario:
-------------------------
ResultSet rs = stmt.executeQuery( "SELECT 1 FROM schema.table FETCH  FIRST 1 ROWs ONLY WITH UR" );                                                            
  while(rs.next())  {                                                                    
   rs.deleteRow();                                                                       
  } 
------------------------- 
The error only occurs when the resultset contains constants only. The error does NOT occur If actual database coloumns are retrieved.
-------------------------                                                    
ResultSet rs = stmt.executeQuery( "SELECT col1  FROM schema.table FETCH FIRST 1 ROWs ONLY WITH UR" );                                                      
  while(rs.next())  {                                                                    
   rs.deleteRow();                                                                       
  }                                                                                      
-------------------------   
                                 

Cause

This is a DB2 limitation. When retrieving constant only, DB2 does not send schema and table information to client side.

Answer

Combine DELETE and SELECT into one statement.

"DELETE FROM (SELECT 1 FROM schema.table FETCH FIRST 1 ROW ONLY)"


Related information

Comparison of driver support for JDBC APIs

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

DB2 for Linux, UNIX and Windows
DB2 Programming Interfaces - JCC

Software version:

9.1

Operating system(s):

Windows

Reference #:

1305865

Modified date:

2008-05-28

Translate my page

Machine Translation

Content navigation