Constructor
new StatementIterator(sql, db)
Parameters:
Name | Type | Description |
---|---|---|
sql | string | A string containing multiple SQL statements |
db | Database | The database from which this iterator was created |
Example
// loop over and execute statements in string sql
for (let statement of db.iterateStatements(sql)) {
statement.step();
// get results, etc.
// do not call statement.free() manually, each statement is freed
// before the next one is parsed
}
// capture any bad query exceptions with feedback
// on the bad sql
let it = db.iterateStatements(sql);
try {
for (let statement of it) {
statement.step();
}
} catch(e) {
console.log(
`The SQL string "${it.getRemainingSQL()}" ` +
`contains the following error: ${e}`
);
}
Methods
["getRemainingSQL"]() → {String}
Get any un-executed portions remaining of the original SQL string
Returns:
- Type:
- String
["next"]() → {StatementIterator.StatementIteratorResult}
Prepare the next available SQL statement
Throws:
SQLite error or invalid iterator error
- Type
- String
Returns:
Type Definitions
StatementIteratorResult
Type:
Properties- Object |
Object
Name | Type | Description |
---|---|---|
value | Statement | the next available Statement (as returned by Database.prepare) |
done | boolean | true if there are no more available statements |