List:MySQL and Java« Previous MessageNext Message »
From:Morten Norby Larsen Date:October 2 2003 11:13am
Subject:Updatable ResultSets
View as plain text  
I got a bug report from a user indicating that he couldn't edit the result 
of his queries, so I thought of leveraging the Updatable ResultSets in 
Connector/J, as a simple way of providing the feature. I, and now also the 
user in question, know that quite a few queries can never give updatable 
result sets, but the docs state that it is possible  under the following 
circumstances:

"MySQL Connector/J can only update result sets that have come from queries 
on tables that have at least one primary key, the query must select all of 
the primary key(s) and the query can only span one table (i.e. no joins). 
This is outlined in the JDBC specification. "

Since this is JDBC material, I'll leave it at that, but I guess that the 
concept could easily be extended to joins, provided that the primary keys 
are selected for all tables.

Anyway, my question is: Will the driver report the result sets of the 
following queries as updatable (if id is the primary key of table1)?

SELECT id, sum(col1) FROM table1 GROUP BY col2;

SELECT id, substring(1, 3, col3) FROM table1;

... etc, etc.


Thanks,

Morten





-----------------------------------------------------------------------
Morten Norby Larsen                             morten@stripped
Magister Ludi s.r.l.                          Phone: +39 02 26 11 72 80
Via Battaglia 8, I-20127 Milano, Italy        Fax:   +39 02 28 46 037
                        http://www.magisterludi.com

Thread
Updatable ResultSetsMorten Norby Larsen2 Oct