sqlingvo icon indicating copy to clipboard operation
sqlingvo copied to clipboard

Inserting multiple rows at a time in SQLite

Open herberteuler opened this issue 10 years ago • 2 comments

Hello,

I had a problem when trying sqlingvo on SQLite via sqlite-jdbc 3.7.2. I tried to insert multiple values with (insert :table [] (values [{...}])) but got error [SQLITE_ERROR] SQL error or missing database (near ",": syntax error).

There are two ways to fix this problem: using newer versions of SQLite, or using a different syntax. As far as I know, starting with version 3.7.11 SQLite supports this syntax. I had tried to use sqlite-jdbc 3.7.15-M1 instead and it worked.

On the other hand, according to this entry on stackoverflow, for older versions of SQLite, the compiler can make this work by emitting statements in a different syntax. I had tried to manually write statements and it worked too.

I do not know what the best way is in sqlingvo to provide the different treatments, but it is a little bit confusing now.

Best regards, Guanpeng Xu

herberteuler avatar Jun 17 '14 04:06 herberteuler

Hi herberteuler,

I mostly use this library together with PostgreSQL. Unitl now I got around generating database specific SQL (or at least it was specific to PostgreSQL), and I'm not sure if I even want to get into this business.

So, at the moment this is not possible. You can always redefine the compile-sql multimethod and (:insert for example) emit your own SQL. I would also accept a patch for that with proper tests.

Roman

r0man avatar Jun 17 '14 07:06 r0man

Okay, I see. I have just started using jdbc and sqlingvo, and my knowledge at this point is not enough for creating a good patch. Currently I am satisfied with using a new version of sqlite-jdbc. I will look into the details later.

Thank you.

Sincerely yours, Guanpeng Xu

herberteuler avatar Jun 17 '14 07:06 herberteuler