In Positive test 47 you check to see what happens if you call insertRow() without setting any of the column values.
You code will just do nothing in this case, no exceptions, insertRow just returns having done nothing due to:
+ if (currentRowHasBeenUpdated == false) // not columns got updated
+ return; //nothing to do since no updateXXX method has been called
But that got me thinking, if a table's columns in the result set then why can't I do an insert without setting any values?
E.g. on a result set of SELECT A,B FROM T, execute INSERT INTO T VALUES DEFAULT
Then I looked at the javadoc for insertRow (JDK142) and it says:
SQLException - if a database access error occurs, if this method is called when the cursor is not on the insert row, or if not all of non-nullable columns in the insert row have been given a value
You code does not throw that exception, but it's a strange wording. It implies to me that with the above SELECT if I set only A then the correct SQL is
INSERT INTO T(A,B) VALUES (?, NULL) [I don't this is correct, but it's what that wording implies]
rather than what you are executing,
INSERT INTO T(A) VALUES
which is the same as
INSERT INTO T(A,B) VALUES (?, DEFAULT)
The JDBC 3.0 spec is somewhat clearer, from section: 184.108.40.206 Inserting a Row
Each column in the insert row that does not allow null as a value and does not
have a default value must be given a value using the approriate update method. If
this is not the case, the method insertRow will throw an SQLException.
I'm still unclear as to why the reference to not allowing null, that does not seem relevant.
So, since the engine will throw the SQLException if a value does not have a default, I believe that an insertRow
with no modified columns should be allowed and should insert a row.