db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel John Debrunner (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-100) Add support for insert functionality using JDBC 2.0 updatable resultset apis
Date Thu, 22 Dec 2005 16:29:32 GMT
    [ http://issues.apache.org/jira/browse/DERBY-100?page=comments#action_12361118 ] 

Daniel John Debrunner commented on DERBY-100:

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,

which is the same as

The JDBC 3.0 spec is somewhat clearer, from section: 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.

> Add support for insert functionality using JDBC 2.0 updatable resultset apis
> ----------------------------------------------------------------------------
>          Key: DERBY-100
>          URL: http://issues.apache.org/jira/browse/DERBY-100
>      Project: Derby
>         Type: New Feature
>   Components: JDBC
>     Versions:
>     Reporter: Mamta A. Satoor
>     Assignee: Fernanda Pizzorno
>  Attachments: DERBY-100.diff, DERBY-100.stat
> The JDBC 2.0 API introduced the ability to update/delete/insert rows from a resultset
using methods in the Java programming language rather than having to send an SQL command.
This Jira entry is to track the insert rows functionality using JDBC 2.0 apis.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message