Question

If I try to execute the following sql command from Flex (ActionScript) code:

INSERT INTO table_name (field1, field2) VALUES (1, 0), (2, 1), (3, 1), (4, 0)

i'm getting the following error:

SQLError: 'Error #3115: SQL Error.', details:'near ',': syntax error', operation:'execute', detailID:'2003'
    at flash.data::SQLStatement/internalExecute()
    at flash.data::SQLStatement/execute()

If I try the same for only one value pair, it works fine:

INSERT INTO table_name (field1, field2) VALUES (15, 66)

SQLite was supposed to support multiple row inserts, right? I tried to copy 1st generated SQL statement to SQLite Expert and paste it into it's SQL tab and it also works fine, populating all the pairs to the table.

What am I doing wrong? Thanks.

Was it helpful?

Solution

The syntax for SQL-lite is different then other "sql" syntax such as the one you have written above. The syntax for what you try to accomplish in SQL-lite is:

 INSERT INTO 'table_name'
      SELECT '1' AS 'field1', '0' AS 'field2'
UNION SELECT '2', '1'
UNION SELECT '3', '1'
UNION SELECT '4', '0'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top