Begins a transaction. A transaction is a set of multiple "writing" statements that are atomically committed, hence all changes will be made or no changes will be made. As a side effect those statements will be executed significantly faster (in the default case a transaction is implicitly created for each statement). It is very important to handle transaction carefully and close them. The transaction is considered successful only if TransactionSuccessful is called. Otherwise no changes will be made. Typical usage: SQL1.BeginTransaction Try 'block of statements like: Fori = 1to1000 SQL1.ExecNonQuery("INSERT INTO table1 VALUES(...) Next SQL1.TransactionSuccessful Catch Log(LastException.Message) 'no changes will be made EndTry SQL1.EndTransaction
Close
Closes the database. Does not do anything if the database is not opened or was closed before.
EndTransaction
Ends the transaction.
ExecNonQuery (StatementAsString)
Executes a single non query SQL statement. Example: SQL1.ExecNonQuery("CREATE TABLE table1 (col1 TEXT , col2 INTEGER, col3 INTEGER)") If you plan to do many "writing" queries one after another, then you should consider using BeginTransaction / EndTransaction. It will execute significantly faster.
ExecNonQuery2 (StatementAsString, ArgsAsList)
Executes a single non query SQL statement. The statement can include question marks which will be replaced by the items in the given list. Note that Basic4android converts arrays to lists implicitly. The values in the list should be strings, numbers or bytes arrays. Example: SQL1.ExecNonQuery2("INSERT INTO table1 VALUES (?, ?, 0)", ArrayAsObject("some text", 2))
Executes the query and returns a cursor which is used to go over the results. Example: DimCursorAsCursor Cursor = SQL1.ExecQuery("SELECT col1, col2 FROM table1") Fori = 0ToCursor.RowCount - 1 Cursor.Position = i Log(Cursor.GetString("col1")) Log(Cursor.GetInt("col2")) Next
Executes the query and returns a cursor which is used to go over the results. The query can include question marks which will be replaced with the values in the array. Example: DimCursorAsCursor Cursor = sql1.ExecQuery2("SELECT col1 FROM table1 WHERE col3 = ?", ArrayAsString(22)) SQLite will try to convert the string values based on the columns types.
Executes the query and returns the value in the first column and the first row (in the result set). Returns Null if no results were found. Example: DimNumberOfMatchesAsInt NumberOfMatches = SQL1.ExecQuerySingleResult("SELECT count(*) FROM table1 WHERE col2 > 300")
Executes the query and returns the value in the first column and the first row (in the result set). Returns Null if no results were found. Example: DimNumberOfMatchesAsInt NumberOfMatches = SQL1.ExecQuerySingleResult2("SELECT count(*) FROM table1 WHERE col2 > ?", ArrayAsString(300))