Platforms to show: All Mac Windows Linux Cross-Platform
SQLDatabaseMBS.CancelAllCommands
Function:
Cancel all commands for the connection.
Notes: This loops over the list of commands associated with this connection and calls Cancel on them.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 18.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes: This loops over the list of commands associated with this connection and calls Cancel on them.
SQLDatabaseMBS.Commands as SQLCommandMBS()
Function:
Queries list of all command objects related to the connection.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 18.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
SQLDatabaseMBS.Connect as boolean
Function:
Connects to the database.
Example:
Notes:
Returns true on success and false on failure.
Please set the DatabaseName, UserName and Password properties. The Host property is ignored.
The database name must contain the complete information and a prefix for the kind of database.
Use this prefixes: "CubeSQL:", "SQLAnywhere:", "ODBC:", "Oracle:", "SQLServer:", "Firebird:", "InterBase:", "SQLBase:", "DB2:", "Informix:", "Sybase:", "MySQL:", "PostgreSQL:" or "SQLite:".
Connect to Microsoft Access, FileMaker Server (or Pro), Microsoft Visual FoxPro and others via ODBC.
For IPv6 we changed plugin to use , instead of : for the port separator. So please use , to separate port from IP or host.
For Firebird, if you connect to a database and you have 32/64bit mismatch, you get error number 3.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 9.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Example:
dim db as new SQLDatabaseMBS
// where is the library?
db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")
// connect to database
// in this example it is MySQL,
// but can also be Sybase, Informix, Oracle, DB2
// SQLServer, InterBase, SQLBase and ODBC
db.DatabaseName="mysql:192.168.1.80,3306@test"
db.UserName="root"
db.Password=""
// or postgreSQL with timeout and ssl mode
db.DatabaseName="PostgreSQL:127.0.0.1,5432@dbname=postgres connection_timeout=10 sslmode=require"
if db.Connect then
MsgBox "We are connected!"
MsgBox "Server Version: "+db.Connection.ServerVersionString
// Disconnect is optional
// autodisconnect will ocur in destructor if needed
else
MsgBox db.ErrorMessage
end if
Returns true on success and false on failure.
Please set the DatabaseName, UserName and Password properties. The Host property is ignored.
The database name must contain the complete information and a prefix for the kind of database.
Use this prefixes: "CubeSQL:", "SQLAnywhere:", "ODBC:", "Oracle:", "SQLServer:", "Firebird:", "InterBase:", "SQLBase:", "DB2:", "Informix:", "Sybase:", "MySQL:", "PostgreSQL:" or "SQLite:".
Connect to Microsoft Access, FileMaker Server (or Pro), Microsoft Visual FoxPro and others via ODBC.
For IPv6 we changed plugin to use , instead of : for the port separator. So please use , to separate port from IP or host.
For Firebird, if you connect to a database and you have 32/64bit mismatch, you get error number 3.
SQLDatabaseMBS.ConnectMT as Boolean
Function:
Connects to the database.
Notes:
Returns true on success and false on failure.
Please set the DatabaseName, UserName and Password properties. The Host property is ignored.
The database name must contain the complete information and a prefix for the kind of database.
Use this prefixes: "CubeSQL:", "SQLAnywhere:", "ODBC:", "Oracle:", "SQLServer:", "Firebird:", "InterBase:", "SQLBase:", "DB2:", "Informix:", "Sybase:", "MySQL:", "PostgreSQL:" or "SQLite:".
Connect to Microsoft Access, FileMaker Server (or Pro), Microsoft Visual FoxPro and others via ODBC.
For IPv6 we changed plugin to use , instead of : for the port separator. So please use , to separate port from IP or host.
Same as Connect, but if you run this on a thread, the plugin gives time to other threads so the rest of your application runs just fine.
The MT method will not trigger WillConnect and DidConnect events.
The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 15.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Returns true on success and false on failure.
Please set the DatabaseName, UserName and Password properties. The Host property is ignored.
The database name must contain the complete information and a prefix for the kind of database.
Use this prefixes: "CubeSQL:", "SQLAnywhere:", "ODBC:", "Oracle:", "SQLServer:", "Firebird:", "InterBase:", "SQLBase:", "DB2:", "Informix:", "Sybase:", "MySQL:", "PostgreSQL:" or "SQLite:".
Connect to Microsoft Access, FileMaker Server (or Pro), Microsoft Visual FoxPro and others via ODBC.
For IPv6 we changed plugin to use , instead of : for the port separator. So please use , to separate port from IP or host.
Same as Connect, but if you run this on a thread, the plugin gives time to other threads so the rest of your application runs just fine.
The MT method will not trigger WillConnect and DidConnect events.
The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
SQLDatabaseMBS.Constructor(globals as SQLGlobalsMBS = nil)
Function:
The constructor.
Notes: Please don't call this directly as it's called automatically with using new command.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 13.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes: Please don't call this directly as it's called automatically with using new command.
SQLDatabaseMBS.CubeSQLLastInsertID as Int64
Function:
Returns the last auto increment value from last insert command.
Notes: Only for CubeSQL connections. May raise error if not available.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 20.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes: Only for CubeSQL connections. May raise error if not available.
SQLDatabaseMBS.CubeSQLReceiveData(byref data as String, byref IsEndChunk as Boolean) as Boolean
Function:
Receives a data chunk for file download.
Notes:
Returns true on success.
Data is set with data and IsEndChunk is set to true for last chunk.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Returns true on success.
Data is set with data and IsEndChunk is set to true for last chunk.
SQLDatabaseMBS.CubeSQLSendData(data as MemoryBlock)
Function:
Sends data chunk for file upload.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
See also:
SQLDatabaseMBS.CubeSQLSendData(data as String)
Function:
Sends data chunk for file upload.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
See also:
SQLDatabaseMBS.CubeSQLSendEndData
Function:
Sends end data packet.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
SQLDatabaseMBS.InsertRecord(TableName as String, Record as Dictionary)
Function:
Convenience function to insert a record.
Example:
Notes:
The plugin builds for you SQL statement with prepared statement and runs the insert command with values.
Lasterror is set or exception raised as with SQLExecute.
You can check statement via LastStatement property.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 18.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Example:
dim db as SQLDatabaseMBS // your database connection
dim d as new Dictionary
d.Value("ID")=2
d.Value("text")="test insert"
d.Value("other")="Just a test"
db.InsertRecord("test_tbl", d)
if db.Error then
MsgBox db.ErrorMessage
end if
The plugin builds for you SQL statement with prepared statement and runs the insert command with values.
Lasterror is set or exception raised as with SQLExecute.
You can check statement via LastStatement property.
SQLDatabaseMBS.Listen
Function:
Start listening for notifications.
Notes:
Works only for PostgresSQL Client.
Please set client or connect before calling this method.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 15.1 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Works only for PostgresSQL Client.
Please set client or connect before calling this method.
SQLDatabaseMBS.MySQLInsertID as Int64
Function:
Returns the last auto increment value from last insert command.
Notes:
Please query value right after doing Insert. This value is reset when you call commit.
see also
http://dev.mysql.com/doc/refman/5.1/en/mysql-insert-id.html
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Please query value right after doing Insert. This value is reset when you call commit.
see also
http://dev.mysql.com/doc/refman/5.1/en/mysql-insert-id.html
SQLDatabaseMBS.Option(name as string) as string
Function:
Sets an option for the connection.
Example:
Notes:
(Read and Write computed property)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | SQL | MBS SQL Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Example:
dim c as SQLDatabaseMBS // your database connection
// for Microsoft SQL use OLEDB, so you don't need native SQL drivers installed...
c.Option("UseAPI") = "OLEDB"
c.Option("SQLNCLI.LIBS") = "sqlsrv32.dll" // Library included in Windows Vista and newer
// for SQLite, set flag to open database file read only:
c.Option("SQLiteVFSFlags") = "1"
// turn on auto cache
c.Option("AutoCache") = "true"
// set connection timeout for ODBC:
c.Option("SQL_ATTR_CONNECTION_TIMEOUT") = "10"
SQLDatabaseMBS.Prepare(statement as string) as SQLPreparedStatementMBS
Function:
Prepares a statement.
Notes:
Returns prepared statement or nil in case of error.
Please check ErrorMessage property for errors.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 16.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Returns prepared statement or nil in case of error.
Please check ErrorMessage property for errors.
SQLDatabaseMBS.SetFileOption(name as string, file as folderitem)
Function:
Sets an option with passing a file path.
Example:
Notes:
Makes sure the path is correct and you have a 32 or 64-bit library matching the architecture of your application.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Example:
dim db as new SQLDatabaseMBS
// where is the library?
db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")
SQLDatabaseMBS.SQLExecute(ExecuteString as string, CommandType as Integer)
Function:
Runs the SQLExecute threaded.
Notes: Same as SQLExecute, but with additional CommandType parameter.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 13.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes: Same as SQLExecute, but with additional CommandType parameter.
SQLDatabaseMBS.SQLExecuteMT(ExecuteString as string, CommandType as Integer = 0)
Function:
Runs the SQLExecute threaded.
Notes:
Same as SQLExecute, but if you run this on a thread, the plugin gives time to other threads so the rest of your application runs just fine.
The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 12.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Same as SQLExecute, but if you run this on a thread, the plugin gives time to other threads so the rest of your application runs just fine.
The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
SQLDatabaseMBS.SQLiteBackupFinish(Backup as SQLite3BackupMBS) as integer
Function:
Finishes a backup run.
Notes:
When BackupStep has returned kErrorDone, or when the application wishes to abandon the backup operation, the application should destroy the SQLite3BackupMBS by passing it to BackupFinish. The BackupFinish interfaces releases all resources associated with the SQLite3BackupMBS object. If BackupStep has not yet returned kErrorDone, then any active write-transaction on the destination database is rolled back. The SQLite3BackupMBS object is invalid and may not be used following a call to BackupFinish.
The value returned by BackupFinish is kErrorOK if no BackupStep errors occurred, regardless or whether or not BackupStep completed. If an out-of-memory condition or IO error occurred during any prior BackupStep call on the same SQLite3BackupMBS object, then BackupFinish returns the corresponding error code.
A return of kErrorBusy or kErrorLocked from BackupStep is not a permanent error and does not affect the return value of BackupFinish.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
When BackupStep has returned kErrorDone, or when the application wishes to abandon the backup operation, the application should destroy the SQLite3BackupMBS by passing it to BackupFinish. The BackupFinish interfaces releases all resources associated with the SQLite3BackupMBS object. If BackupStep has not yet returned kErrorDone, then any active write-transaction on the destination database is rolled back. The SQLite3BackupMBS object is invalid and may not be used following a call to BackupFinish.
The value returned by BackupFinish is kErrorOK if no BackupStep errors occurred, regardless or whether or not BackupStep completed. If an out-of-memory condition or IO error occurred during any prior BackupStep call on the same SQLite3BackupMBS object, then BackupFinish returns the corresponding error code.
A return of kErrorBusy or kErrorLocked from BackupStep is not a permanent error and does not affect the return value of BackupFinish.
SQLDatabaseMBS.SQLiteBackupInit(Dest as Variant, DestName as String, Source as Variant, SourceName as String) as SQLite3BackupMBS
Function:
Initializes a backup.
Notes:
The backup API copies the content of one database into another. It is useful either for creating backups of databases or for copying in-memory databases to or from persistent files.
see also
http://www.sqlite.org/c3ref/backup_finish.html
Exclusive access is required to the destination database for the duration of the operation. However the source database is only read-locked while it is actually being read; it is not locked continuously for the entire backup operation. Thus, the backup may be performed on a live source database without preventing other users from reading or writing to the source database while the backup is underway.
To perform a backup operation:
The D and N arguments to BackupInit(D,N,S,M) are the database connection associated with the destination database and the database name, respectively. The database name is "main" for the main database, "temp" for the temporary database, or the name specified after the AS keyword in an ATTACH statement for an attached database. The S and M arguments passed to BackupInit(D,N,S,M) identify the database connection and database name of the source database, respectively. The source and destination database connections (parameters S and D) must be different or else BackupInit(D,N,S,M) will file with an error.
If an error occurs within BackupInit(D,N,S,M), then nil is returned and an error code and error message are store3d in the destination database connection D. The error code and message for the failed call to BackupInit can be retrieved using the ErrCode and ErrMessage functions. A successful call to BackupInit returns a SQLite3BackupMBS object. The SQLite3BackupMBS object may be used with the BackupStep and BackupFinish functions to perform the specified backup operation.
Concurrent Usage of Database Handles
The source database connection may be used by the application for other purposes while a backup operation is underway or being initialized. If SQLite is compiled and configured to support threadsafe database connections, then the source database connection may be used concurrently from within other threads.
However, the application must guarantee that the destination database connection is not passed to any other API (by any thread) after BackupInit is called and before the corresponding call to BackupFinish. SQLite does not currently check to see if the application incorrectly accesses the destination database connection and so no error code is reported, but the operations may malfunction nevertheless. Use of the destination database connection while a backup is in progress might also also cause a mutex deadlock.
If running in shared cache mode, the application must guarantee that the shared cache used by the destination database is not accessed while the backup is running. In practice this means that the application must guarantee that the disk file being backed up to is not accessed by any connection within the process, not just the specific connection that was passed to BackupInit.
The SQLite3BackupMBS object itself is partially threadsafe. Multiple threads may safely make multiple concurrent calls to BackupStep. However, the BackupRemaining and BackupPageCount APIs are not strictly speaking threadsafe. If they are invoked at the same time as another thread is invoking BackupStep it is possible that they return invalid values.
Source and Dest can be SQLConnectionMBS or SQLDatabaseMBS. You need to pass source and dest, even if one is self as we give you the option to decide where to pass the current database connection.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
The backup API copies the content of one database into another. It is useful either for creating backups of databases or for copying in-memory databases to or from persistent files.
see also
http://www.sqlite.org/c3ref/backup_finish.html
Exclusive access is required to the destination database for the duration of the operation. However the source database is only read-locked while it is actually being read; it is not locked continuously for the entire backup operation. Thus, the backup may be performed on a live source database without preventing other users from reading or writing to the source database while the backup is underway.
To perform a backup operation:
- BackupInit is called once to initialize the backup,
- BackupStep is called one or more times to transfer the data between the two databases, and finally
- BackupFinish is called to release all resources associated with the backup operation.
The D and N arguments to BackupInit(D,N,S,M) are the database connection associated with the destination database and the database name, respectively. The database name is "main" for the main database, "temp" for the temporary database, or the name specified after the AS keyword in an ATTACH statement for an attached database. The S and M arguments passed to BackupInit(D,N,S,M) identify the database connection and database name of the source database, respectively. The source and destination database connections (parameters S and D) must be different or else BackupInit(D,N,S,M) will file with an error.
If an error occurs within BackupInit(D,N,S,M), then nil is returned and an error code and error message are store3d in the destination database connection D. The error code and message for the failed call to BackupInit can be retrieved using the ErrCode and ErrMessage functions. A successful call to BackupInit returns a SQLite3BackupMBS object. The SQLite3BackupMBS object may be used with the BackupStep and BackupFinish functions to perform the specified backup operation.
Concurrent Usage of Database Handles
The source database connection may be used by the application for other purposes while a backup operation is underway or being initialized. If SQLite is compiled and configured to support threadsafe database connections, then the source database connection may be used concurrently from within other threads.
However, the application must guarantee that the destination database connection is not passed to any other API (by any thread) after BackupInit is called and before the corresponding call to BackupFinish. SQLite does not currently check to see if the application incorrectly accesses the destination database connection and so no error code is reported, but the operations may malfunction nevertheless. Use of the destination database connection while a backup is in progress might also also cause a mutex deadlock.
If running in shared cache mode, the application must guarantee that the shared cache used by the destination database is not accessed while the backup is running. In practice this means that the application must guarantee that the disk file being backed up to is not accessed by any connection within the process, not just the specific connection that was passed to BackupInit.
The SQLite3BackupMBS object itself is partially threadsafe. Multiple threads may safely make multiple concurrent calls to BackupStep. However, the BackupRemaining and BackupPageCount APIs are not strictly speaking threadsafe. If they are invoked at the same time as another thread is invoking BackupStep it is possible that they return invalid values.
Source and Dest can be SQLConnectionMBS or SQLDatabaseMBS. You need to pass source and dest, even if one is self as we give you the option to decide where to pass the current database connection.
SQLDatabaseMBS.SQLiteBackupPageCount(Backup as SQLite3BackupMBS) as integer
Function:
Returns the number of pages in total.
Notes:
Each call to BackupStep sets two values inside the SQLite3BackupMBS object: the number of pages still to be backed up and the total number of pages in the source databae file. The BackupRemaining and BackupPageCount interfaces retrieve these two values, respectively.
The values returned by these functions are only updated by BackupStep. If the source database is modified during a backup operation, then the values are not updated to account for any extra pages that need to be updated or the size of the source database file changing.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Each call to BackupStep sets two values inside the SQLite3BackupMBS object: the number of pages still to be backed up and the total number of pages in the source databae file. The BackupRemaining and BackupPageCount interfaces retrieve these two values, respectively.
The values returned by these functions are only updated by BackupStep. If the source database is modified during a backup operation, then the values are not updated to account for any extra pages that need to be updated or the size of the source database file changing.
SQLDatabaseMBS.SQLiteBackupRemaining(Backup as SQLite3BackupMBS) as integer
Function:
Returns the number of pages remaining.
Notes:
Each call to BackupStep sets two values inside the SQLite3BackupMBS object: the number of pages still to be backed up and the total number of pages in the source databae file. The BackupRemaining and BackupPageCount interfaces retrieve these two values, respectively.
The values returned by these functions are only updated by BackupStep. If the source database is modified during a backup operation, then the values are not updated to account for any extra pages that need to be updated or the size of the source database file changing.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Each call to BackupStep sets two values inside the SQLite3BackupMBS object: the number of pages still to be backed up and the total number of pages in the source databae file. The BackupRemaining and BackupPageCount interfaces retrieve these two values, respectively.
The values returned by these functions are only updated by BackupStep. If the source database is modified during a backup operation, then the values are not updated to account for any extra pages that need to be updated or the size of the source database file changing.
SQLDatabaseMBS.SQLiteBackupStep(Backup as SQLite3BackupMBS, Pages as Integer) as integer
Function:
Copies up to Pages pages between the source and destination databases specified by SQLite3BackupMBS object.
Notes:
If N is negative, all remaining source pages are copied. If BackupStep(B,N) successfully copies N pages and there are still more pages to be copied, then the function resturns kErrorOK. If BackupStep(B,N) successfully finishes copying all pages from source to destination, then it returns kErrorDone. If an error occurs while running BackupStep(B,N), then an error code is returned. As well as kErrorOK and kErrorDone, a call to BackupStep may return kErrorReadOnly, kErrorNoMem, kErrorBusy, kErrorLocked, or an kErrorIOACCESS | kErrorIOXXX extended error code.
The BackupStep might return kErrorReadOnly if the destination database was opened read-only or if the destination is an in-memory database with a different page size from the source database.
If BackupStep cannot obtain a required file-system lock, then the sqlite3_busy_handler | busy-handler function is invoked (if one is specified). If the busy-handler returns non-zero before the lock is available, then kErrorBusy is returned to the caller. In this case the call to BackupStep can be retried later. If the source database connection is being used to write to the source database when BackupStep is called, then kErrorLocked is returned immediately. Again, in this case the call to BackupStep can be retried later on. (If kErrorIOACCESS | kErrorIOXXX, kErrorNoMem, or kErrorReadOnly is returned, then there is no point in retrying the call to BackupStep. These errors are considered fatal.) The application must accept that the backup operation has failed and pass the backup operation handle to the BackupFinish to release associated resources.
The first call to BackupStep obtains an exclusive lock on the destination file. The exclusive lock is not released until either BackupFinish is called or the backup operation is complete and BackupStep returns kErrorDone. Every call to BackupStep obtains a shared lock on the source database that lasts for the duration of the BackupStep call. Because the source database is not locked between calls to BackupStep, the source database may be modified mid-way through the backup process. If the source database is modified by an external process or via a database connection other than the one being used by the backup operation, then the backup will be automatically restarted by the next call to BackupStep. If the source database is modified by the using the same database connection as is used by the backup operation, then the backup database is automatically updated at the same time.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
If N is negative, all remaining source pages are copied. If BackupStep(B,N) successfully copies N pages and there are still more pages to be copied, then the function resturns kErrorOK. If BackupStep(B,N) successfully finishes copying all pages from source to destination, then it returns kErrorDone. If an error occurs while running BackupStep(B,N), then an error code is returned. As well as kErrorOK and kErrorDone, a call to BackupStep may return kErrorReadOnly, kErrorNoMem, kErrorBusy, kErrorLocked, or an kErrorIOACCESS | kErrorIOXXX extended error code.
The BackupStep might return kErrorReadOnly if the destination database was opened read-only or if the destination is an in-memory database with a different page size from the source database.
If BackupStep cannot obtain a required file-system lock, then the sqlite3_busy_handler | busy-handler function is invoked (if one is specified). If the busy-handler returns non-zero before the lock is available, then kErrorBusy is returned to the caller. In this case the call to BackupStep can be retried later. If the source database connection is being used to write to the source database when BackupStep is called, then kErrorLocked is returned immediately. Again, in this case the call to BackupStep can be retried later on. (If kErrorIOACCESS | kErrorIOXXX, kErrorNoMem, or kErrorReadOnly is returned, then there is no point in retrying the call to BackupStep. These errors are considered fatal.) The application must accept that the backup operation has failed and pass the backup operation handle to the BackupFinish to release associated resources.
The first call to BackupStep obtains an exclusive lock on the destination file. The exclusive lock is not released until either BackupFinish is called or the backup operation is complete and BackupStep returns kErrorDone. Every call to BackupStep obtains a shared lock on the source database that lasts for the duration of the BackupStep call. Because the source database is not locked between calls to BackupStep, the source database may be modified mid-way through the backup process. If the source database is modified by an external process or via a database connection other than the one being used by the backup operation, then the backup will be automatically restarted by the next call to BackupStep. If the source database is modified by the using the same database connection as is used by the backup operation, then the backup database is automatically updated at the same time.
SQLDatabaseMBS.SQLiteEnableLoadExtension(OnOff as boolean)
Function:
Enables/disables extension loading for the given connection.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
SQLDatabaseMBS.SQLiteLastInsertRowID as Int64
Function:
Returns Last Insert Rowid.
Notes:
Each entry in an SQLite table has a unique 64-bit signed integer key called the ROWID. The rowid is always available as an undeclared column named ROWID, OID, or _ROWID_ as long as those names are not also used by explicitly declared columns. If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.
This routine returns the rowid of the most recent successful INSERT into the database from the database connection in the first argument. If no successful INSERTs have ever occurred on that database connection, zero is returned.
(If an INSERT occurs within a trigger, then the rowid of the inserted row is returned by this routine as long as the trigger is running. But once the trigger terminates, the value returned by this routine reverts to the last value inserted before the trigger fired.)
An INSERT that fails due to a constraint violation is not a successful INSERT and does not change the value returned by this routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, and INSERT OR ABORT make no changes to the return value of this routine when their insertion fails. ^(When INSERT OR REPLACE encounters a constraint violation, it does not fail. The INSERT continues to completion after deleting rows that caused the constraint problem so INSERT OR REPLACE will always change the return value of this interface.)^
For the purposes of this routine, an INSERT is considered to be successful even if it is subsequently rolled back.
This function is accessible to SQL statements via the last_insert_rowid() SQL function.
If a separate thread performs a new INSERT on the same database connection while the LastInsertRowID function is running and thus changes the last insert rowid, then the value returned by LastInsertRowID is unpredictable and might not equal either the old or the new last insert rowid.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
Each entry in an SQLite table has a unique 64-bit signed integer key called the ROWID. The rowid is always available as an undeclared column named ROWID, OID, or _ROWID_ as long as those names are not also used by explicitly declared columns. If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.
This routine returns the rowid of the most recent successful INSERT into the database from the database connection in the first argument. If no successful INSERTs have ever occurred on that database connection, zero is returned.
(If an INSERT occurs within a trigger, then the rowid of the inserted row is returned by this routine as long as the trigger is running. But once the trigger terminates, the value returned by this routine reverts to the last value inserted before the trigger fired.)
An INSERT that fails due to a constraint violation is not a successful INSERT and does not change the value returned by this routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, and INSERT OR ABORT make no changes to the return value of this routine when their insertion fails. ^(When INSERT OR REPLACE encounters a constraint violation, it does not fail. The INSERT continues to completion after deleting rows that caused the constraint problem so INSERT OR REPLACE will always change the return value of this interface.)^
For the purposes of this routine, an INSERT is considered to be successful even if it is subsequently rolled back.
This function is accessible to SQL statements via the last_insert_rowid() SQL function.
If a separate thread performs a new INSERT on the same database connection while the LastInsertRowID function is running and thus changes the last insert rowid, then the value returned by LastInsertRowID is unpredictable and might not equal either the old or the new last insert rowid.
SQLDatabaseMBS.SQLiteLibVersion as String
Function:
Queries the version string of the SQLite library.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
SQLDatabaseMBS.SQLiteLoadExtension(file as FolderItem, ByRef ErrorMessage as String) as Integer
Function:
Loads an SQLite extension library from the named file.
Notes:
The LoadExtension interface attempts to load an SQLite extension library contained in the file.
Returns kErrorOk on success and kErrorError if something goes wrong.
Extension loading must be enabled using EnableLoadExtension prior to calling this API, otherwise an error will be returned.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
The LoadExtension interface attempts to load an SQLite extension library contained in the file.
Returns kErrorOk on success and kErrorError if something goes wrong.
Extension loading must be enabled using EnableLoadExtension prior to calling this API, otherwise an error will be returned.
See also:
SQLDatabaseMBS.SQLiteLoadExtension(path as String, ByRef ErrorMessage as String) as Integer
Function:
Loads an SQLite extension library from the named file.
Notes:
The LoadExtension interface attempts to load an SQLite extension library contained in the file.
Returns kErrorOk on success and kErrorError if something goes wrong.
Extension loading must be enabled using EnableLoadExtension prior to calling this API, otherwise an error will be returned.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes:
The LoadExtension interface attempts to load an SQLite extension library contained in the file.
Returns kErrorOk on success and kErrorError if something goes wrong.
Extension loading must be enabled using EnableLoadExtension prior to calling this API, otherwise an error will be returned.
See also:
SQLDatabaseMBS.SQLiteMemoryHighwater(reset as boolean = false) as Int64
Function:
Queries maximum memory usage so far.
Notes: Can be reset with reset parameter being true.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | SQL | MBS SQL Plugin | 19.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Notes: Can be reset with reset parameter being true.
The items on this page are in the following plugins: MBS SQL Plugin.

Links
MBS Xojo Plugins