문제

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.

도움이 되었습니까?

해결책

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'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top