Platforms to show: All Mac Windows Linux Cross-Platform

Back to SQLDatabaseMBS class.

SQLDatabaseMBS.BeginTransaction

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 22.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Begins a transaction.

This method does nothing. Why?
Well, if auto commit is on, you don't need to call this.
If auto commit is off, we call BeginTransaction for you, so if you call this method you would call it a second time and get an error.
We have this method for compatibility to other SQL database classes from Xojo.

SQLDatabaseMBS.InsertRecord(TableName as String, Record as Dictionary)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 18.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Convenience function to insert a record.
Example
Var db as SQLDatabaseMBS // your database connection

Var 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.
Internally this uses a prepared statement. You can check the generated statement via LastStatement property.

SQLDatabaseMBS.Listen

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 15.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Start listening for notifications.

Works only for PostgresSQL Client.
Please set client or connect before calling this method.

SQLDatabaseMBS.MySQLInsertID as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 19.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the last auto increment value from last insert command.

Please query value right after doing Insert. This value is reset when you call commit.
For mySQL and MariaDB connections.

see also
http://dev.mysql.com/doc/refman/5.1/en/mysql-insert-id.html

SQLDatabaseMBS.Option(name as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property SQL MBS SQL Plugin 10.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Sets an option for the connection.
Example
Var 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"

// cache insert statements for AddRow/InsertRecord
c.Option("CacheInsertStatement") = "true"

We have a collection of library files here:
https://www.monkeybreadsoftware.de/xojo/download/plugin/Libs/
(Read and Write computed property)

SQLDatabaseMBS.Prepare(statement as string) as SQLPreparedStatementMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 16.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Prepares a statement.

Returns prepared statement or nil in case of error.
Please check ErrorMessage property for errors.

SQLDatabaseMBS.UpdateRecord(TableName as String, Record as Dictionary, Keys as Dictionary)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method SQL MBS SQL Plugin 18.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Convenience function to update a record.
Example
Var db as SQLDatabaseMBS // your database connection

Var d as new Dictionary

d.Value("text")="new text"
d.Value("other")="second value"

db.UpdateRecord("test_tbl", d, new dictionary("ID":2))

if db.Error then
MsgBox db.ErrorMessage
end if

The plugin builds for you SQL statement with prepared statement and runs the update command with given values for records with given key values.

You can put multiple field names in the keys dictionary.

Lasterror is set or exception raised as with SQLExecute.
Internally this uses a prepared statement. You can check the generated statement via LastStatement property.

The items on this page are in the following plugins: MBS SQL Plugin.


The biggest plugin in space...