Platforms to show: All Mac Windows Linux Cross-Platform
SQLCommandMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | SQL | MBS SQL Plugin | 9.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
The plugin can cache the recordset locally. To enable you can call SQLCommandMBS.Cache or use the Option("AutoCache") = "true" on either command or connection or database objects. The plugin will than fetch all records and store them in memory. After this you can walk over the recordset and use FetchPos, FetchFirst, FetchLast, FetchPrev and FetchNext to locate the rows you need. When you call Field() you always get last row, but to read from cached result set, please use Value() function. When using RecordSet, the values are read via Value() functions automatically.
see also
https://www.sqlapi.com/ApiDoc/class_s_a_command.html
- 2 events
- 18 properties
- property CommandText as string
- property CommandType as Integer
- property Connection as SQLConnectionMBS
- property FieldCount as Integer
- property Fields as Dictionary
- property hasCache as Boolean
- property isBOF as Boolean
- property isEOF as Boolean
- property isExecuted as boolean
- property isExecuting as Boolean
- property isOpened as boolean
- property isResultSet as boolean
- property Options as Dictionary
- property ParamCount as Integer
- property Parameters as Dictionary
- property RowsAffected as Integer
- property Tag as Variant
- property Option(name as string) as string
- shared property CommandCount as Integer
- 38 methods
- method AsRecordSet as RecordSet
- method AsRowSet as RowSet
- method Cache
- method Cancel
- method Close
- method Constructor
- method Constructor(connection as SQLConnectionMBS, SQLCommand as String, CommandType as Integer = 0)
- method CreateParam(name as string, ParamType as Integer, DirType as Integer=0) as SQLParamMBS
- method CreateParam(name as string, ParamType as Integer, NativeType as Integer, ParamSize as Integer, ParamPrecision as Integer, ParamScale as Integer, DirType as Integer=0) as SQLParamMBS
- method DB2SQLExecDirect(sql as string)
- method DB2SQLRowCount as Int64
- method DestroyParams
- method Execute
- method ExecuteCommand(SQLCommand as string, CommandType as Integer=0)
- method ExecuteCommandMT(SQLCommand as string, CommandType as Integer=0)
- method ExecuteMT
- method FetchFirst as boolean
- method FetchLast as boolean
- method FetchNext as boolean
- method FetchPos(offset as Integer, relative as boolean = false) as boolean
- method FetchPrior as boolean
- method Field(index as Integer) as SQLFieldMBS
- method Field(name as string) as SQLFieldMBS
- method FieldExists(name as string) as Boolean
- method FieldNames as String()
- method Open
- method Param(ID as Integer) as SQLParamMBS
- method Param(name as string) as SQLParamMBS
- method ParamByIndex(index as Integer) as SQLParamMBS
- method PostgreSQLField(RecordIndex as integer, FieldIndex as integer) as string
- method PostgreSQLField(RecordIndex as integer, FieldName as string) as string
- method PostgreSQLFieldCount as Integer
- method PostgreSQLRowCount as Integer
- method Prepare
- method setCommandText(SQLCommand as string, CommandType as Integer = 0)
- method SetParameters(Params as dictionary)
- method Value(index as Integer) as SQLValueReadMBS
- method Value(name as string) as SQLValueReadMBS
- 9 constants
Constants
Constant | Value | Description |
---|---|---|
kOptionPreFetchRows | "PreFetchRows" | One of the option constants. Example |
kParamDirTypeInput | 0 |
One of the parameter direction type constants.
Input parameter. |
kParamDirTypeInputOutput | 1 |
One of the parameter direction type constants.
Input/output parameter. |
kParamDirTypeOutput | 2 |
One of the parameter direction type constants.
Output parameter. |
kParamDirTypeReturn | 3 |
One of the parameter direction type constants.
Returning parameter. |
Command Types
Constant | Value | Description |
---|---|---|
kCommandTypeSQLStatement | 1 |
Command is an SQL statement. |
kCommandTypeSQLStatementRaw | 2 |
Command is an SQL statement that mustn't be interpreted by SQLAPI. |
kCommandTypeStoredProcedure | 3 |
Command is a stored procedure or a function. |
kCommandTypeUnknown | 0 |
Used by default. Library detects command type automatically. |
This class has no sub classes.
Some methods using this class:
- DB2MBS.SQLRowCount(cmd as SQLCommandMBS) as Int64
- InformixMBS.Error(cmd as SQLCommandMBS, byref SQLState as string, byref NativeError as Integer, byref ErrorMsg as string) as Integer
- InformixMBS.GetCursorName(cmd as SQLCommandMBS) as string
- InformixMBS.HSTMT(cmd as SQLCommandMBS) as Integer
- InformixMBS.SetCursorName(cmd as SQLCommandMBS, name as string) as boolean
- MySQLMBS.NumberOfRows(cmd as SQLCommandMBS) as UInt64
- PostgreSQLAPIMBS.Field(cmd as SQLCommandMBS, RecordIndex as Integer, FieldIndex as Integer) as string
- PostgreSQLAPIMBS.FieldCount(cmd as SQLCommandMBS) as Integer
- SQLConnectionMBS.Commands as SQLCommandMBS()
- SQLDatabaseMBS.Commands as SQLCommandMBS()
Some events using this class:
- SQLConnectionMBS.Trace(traceInfo as Integer, SQL as string, Command as SQLCommandMBS)
- SQLDatabaseMBS.Trace(traceInfo as Integer, SQL as string, Command as SQLCommandMBS)
- SQLGlobalsMBS.Trace(traceInfo as Integer, SQL as string, Connection as SQLConnectionMBS, Command as SQLCommandMBS)
Some examples using this class:
- /SQL/DuckDB Version
- /SQL/MySQL Connect via SSH
- /SQL/MySQL Query Version
- /SQL/PostgreSQL RecordCount
- /SQL/SQL Exception Tests
- /SQL/SQLDatabaseMBS Microsoft SQL Server Data Types
- /SQL/SQLite Blob test
- /SQL/SQLite ExecuteSQL
- /SQL/SQLite Fetch rows bulk
- /SQL/SQLite load extension
Blog Entries
- 15th birthday of MBS SQL Plugin
- Using MBS SQL Plugin with PostgreSQL
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.4
- RowSet in MBS Xojo SQL Plugin
- 10th birthday of MBS SQL Plugin
- Call stored procedures with output parameters
- MonkeyBread Software Releases the MBS Xojo / Real Studio plug-ins in version 14.0
- Multithreaded plugin functions can increase speed of Real Studio application
- RecordSet news
- MBS Plugins 11.1 Release notes
Xojo Developer Magazine
- 14.1, pages 28 to 30: The MBS SQL Plugin, An alternative way to connect to databases by Christian Schmitz
- 14.1, pages 24 to 26: The MBS SQL Plugin, An alternative way to connect to databases by Christian Schmitz
- 12.2, page 10: News
Release notes
- Version 24.0
- Added isBOF and isEOF to SQLCommandMBS class.
- Fixed a problem with Options in SQLCommandMBS not reporting options correctly.
- Version 21.4
- Added FieldExists method to SQLCommandMBS class.
- Version 20.5
- Added code to detect if variant is unsigned, so we can handle UInt32/UInt64 correctly in BigNumberMBS, JavaScriptEngineMBS, SQLPreparedStatementMBS and SQLCommandMBS, SQLValueMBS, and JSONMBS classes and in CFDictionaryMBS/NSDictionary conversion.
- Version 19.5
- Added AsRowSet method to SQLCommandMBS class.
- Added DB2SQLExecDirect and DB2SQLRowCount methods to SQLCommandMBS class.
- Version 19.2
- Added nil object check for SQLCommandMBS.ExecuteMT and similar functions.
- Changed SQLCommandMBS class to clear SQLFieldMBS and SQLParamMBS objects from it in destructor. If you access them later, you'll get SQLNotInitializedExceptionMBS exception.
- Changed SQLConnectionMBS/SQLDatabaseMBS to pass more options to SQLCommandMBS for MS SQL: SQL_ATTR_CURSOR_TYPE, SQL_ATTR_QUERY_TIMEOUT, SQL_ATTR_CONCURRENCY, SQL_ATTR_CURSOR_SCROLLABLE and SQL_ATTR_CURSOR_SENSITIVITY.
- Fixed bug with exception handling for SQLCommandMBS.ExecuteMT method.
- Version 18.1
- Added Options property to SQLDatabaseMBS, SQLConnectionMBS and SQLCommandMBS to inspect options.
The items on this page are in the following plugins: MBS SQL Plugin.