On 22 October 2013 11:42, Noel Grandin <[email protected]> wrote:
> Hi Cemo
>
> Thanks for that. I have one problem remaining. This piece of code in
> Prepare makes no sense:
>
> // check if suitable for update
> for (Column key : keys) {
> boolean found = false;
> for (Column column : columns) {
> if (column.getColumnId() == key.getColumnId()) {
> found = true;
> break;
> }
> }
> if (!found) {
> return;
> }
> }
>
> What exactly is that guarding against, and why is it not throwing an
> exception?
>
> Thanks, Noel.
>
Hi Noel,
I am not sure for H2 and other Database systems but I will try to explain
for MySQL with an analogy.
CREATE TABLE `BAD_WORD` (
`BAD_WORD_ID` int(11) NOT NULL AUTO_INCREMENT,
`WORD` varchar(128) NOT NULL,
PRIMARY KEY (`BAD_WORD_ID`)
);
this statement is totally legal:
REPLACE INTO `bad_word` ( `WORD`) VALUES('bad_boy');
This statement does not raise an exception. It does not need an PK field
too. And I thought that It would be better to optimize process by skipping
update. Because there is any field to help us for an update statement. If I
throw an exception in this case, I can not insert any statement without a
PK field. Hope that It would help you to make clearer.
Please let me know for further details.
Thanks
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.