Hi Dario, Please take your time to read my first post. It is clearly written that I read the documentation before creating this topic. I also looked at the beautiful syntax just to be sure that I was understanding or MERGE was working.
As the graph shows and if I read carefully this sentence taken directly from the documentation: "If no key column is specified, the primary key columns are used to find the row." I assume that the key is OPTIONAL and that it will rely on the primary key to find what it must do. So, based on what I understood, knowing that my table has a primary key (first field), why do I need to specify the key. If I don't specify the key, I get the error shown on my first post. Commentting Dario's post: I'm used to programming groups and forum. I have decent knowledge about how to behave in there. Each time i use these, I really do my best to go as straight-forward as possible and provide as much info as anyone reading could need (stack trace, error message). I must say that I had my worst welcome ever in a programming forum/group in this one. Your message was cold and filled with sarcasm and I really hope that it doesn't represent the H2 database community. Maybe you just had a bad day. I really feel like my message was straight-forward and easy to read. If I misunderstood something in the documentation, you could simply tell me without being so harsh. On Oct 29, 6:59 pm, "Dario V. Fassi" <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
