azsl1326
azsl1326

Reputation: 1410

Flex/AIR SQLite: Multiple Inserts, Unknown Number of Rows in 1 SQL Statement

I am creating a Mobile APP in Flex/Adobe AIR. I am using SQLite to store and retrieve data. I have a situation where I need to INSERT an unknown number of rows into a table. Is there a way to do this with a single statement in SQLite? I know that it can be done using a loop in AS3, but wanted to see if it's possible with a single SQL statement. I have found references to using UNIONS and SELECT, however, the examples weren't completely clear nor was I sure that they were applicable to my situation. Any examples are certainly appreciated.

Thanks.

Upvotes: 0

Views: 1532

Answers (1)

Amy Blankenship
Amy Blankenship

Reputation: 6961

You should be able to do something like:

INSERT INTO SomeTable 
VALUES
('Column 1 Row 1', 'Column 2 Row 1'),
('Column 1 Row 2', 'Column 2 Row 2'),
('Column 1 Row 3', 'Column 2 Row 3');

You'll still need to loop in AS to build the SQL statement, though.

Note that there seems to be some confusion as to whether this syntax is supported by SQLLite.

Upvotes: 1

Related Questions