Hi, Maxime,
Please take your time to read the merge's documentation
(http://www.h2database.com/html/grammar.html#merge) there are a
beautiful syntax graph too.
Merge it's an update OR insert operation, so the only way to know what
to do is to find by Primary KEY of intended new row.
Please be carefull, people that support this group, are working really
hard for H2 and for us, and posts like this make them loose their time.
Regards,
Dario.
Maxime Daigneault escribió:
> As I can read in H2 documentation, MERGE statement should work the
> same as INSERT statement. Only exception is usage of a key, but I
> don't need one because it should rely on primary key.
>
> Assuming this, why this works:
>
> CALL CSVWRITE('test.csv', 'SELECT * FROM NODE');
> (of course, I need to change values in file before inserting it else I
> will get an error because of the primary key)
> INSERT INTO NODE (SELECT * FROM CSVREAD('test.csv'));
>
> And this doesn't work?
>
> CALL CSVWRITE('test.csv', 'SELECT * FROM NODE');
> MERGE INTO NODE (SELECT * FROM CSVREAD('test.csv'));
>
> Really, this should work. This would be just perfect for my needs.
>
> Stack trace:
>
> Syntax error in SQL statement MERGE INTO NODE (SELECT[*] * FROM CSVREAD
> ('test.csv')); expected identifier; SQL statement:
> MERGE INTO NODE (SELECT * FROM CSVREAD('test.csv')) [42001-120]
> 42001/42001 (Help)
> org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement MERGE INTO
> NODE (SELECT[*] * FROM CSVREAD('test.csv')); expected identifier; SQL
> statement:
> MERGE INTO NODE (SELECT * FROM CSVREAD('test.csv')) [42001-120]
> at org.h2.message.Message.getSQLException(Message.java:106)
> at org.h2.message.Message.getSQLException(Message.java:117)
> at org.h2.message.Message.getSyntaxError(Message.java:142)
> at org.h2.command.Parser.readColumnIdentifier(Parser.java:2518)
> at org.h2.command.Parser.parseColumnList(Parser.java:747)
> at org.h2.command.Parser.parseMerge(Parser.java:854)
> at org.h2.command.Parser.parsePrepared(Parser.java:374)
> at org.h2.command.Parser.parse(Parser.java:291)
> at org.h2.command.Parser.parse(Parser.java:263)
> at org.h2.command.Parser.prepareCommand(Parser.java:235)
> at org.h2.engine.Session.prepareLocal(Session.java:415)
> at org.h2.engine.Session.prepareCommand(Session.java:376)
> at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:
> 1049)
> at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:149)
> at org.h2.server.web.WebThread.getResult(WebThread.java:1691)
> at org.h2.server.web.WebThread.query(WebThread.java:1274)
> at org.h2.server.web.WebThread.process(WebThread.java:430)
> at org.h2.server.web.WebThread.processRequest(WebThread.java:183)
> at org.h2.server.web.WebThread.process(WebThread.java:236)
> at org.h2.server.web.WebThread.run(WebThread.java:193)
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---