Sqlite: execute multiple statements?


#1

When using transaction.executeSql() is it possible to execute multiple sql statements at once?

e.g.

CREATE TABLE BlahConfig
(
	key VARCHAR(50),
	val VARCHAR(255)
);
INSERT INTO BlahConfig
VALUES
(
	'db_version',
	'1.00'
),
(
	'dt_created',
	CURRENT_TIMESTAMP
);

it seems this creates the table, but doesn’t execute the insert statement.


#2

@nikki do you know the answer to this?


#3

Has anybody known the answer to this question ? I’m also having the same problem :sweat:


#4

Would calling two separate statements in the same transaction be sufficient for you? Something like this should work.

db.transaction(tx => {
      tx.executeSql(
             `CREATE TABLE BlahConfig
            (
            key VARCHAR(50),
            val VARCHAR(255)
            );`
      );
      tx.executeSql(
             `INSERT INTO BlahConfig
             VALUES
             (
	             'db_version',
	             '1.00'
             ),
             (
	             'dt_created',
	             CURRENT_TIMESTAMP
             );`
      );
});