DatabaseSqlQuery¶
Description¶
The DatabaseSqlQuery object encapsulates a SQL query and handles errors or results.
› Inherits: | Object |
---|
Properties¶
error¶
This property holds the most recently occurred error or DatabaseSqlQuery.NoError if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() signal to detect multiple occurrences of the same error.
› Type: | Error |
---|---|
› Signal: | errorChanged() |
› Attributes: | Readonly |
errorString¶
This property holds the current human readable error string corresponding to the current value in the error property. It may include additional information such as failure reasons or locations.
› Type: | String |
---|---|
› Signal: | errorStringChanged() |
› Attributes: | Readonly |
forwardOnly¶
This property holds whether the query is forward only. For some queries forwardOnly has to be true
to work properly. Forward only mode can be (depending on the driver) more memory efficient since results do not need to be cached. It will also improve performance on some databases.
› Type: | Boolean |
---|---|
› Default: | false |
› Signal: | forwardOnlyChanged() |
› Attributes: | Writable |
lastInsertedId¶
This property holds the object ID of the most recent inserted row if the database supports it. undefined
will be returned if the query did not insert any value or if the database does not report the id back. If more than one row was touched by the insert, the behavior is undefined. For MySQL databases the row’s auto-increment field will be returned.
This property was introduced in InCore 2.3.
› Type: | Variant |
---|---|
› Signal: | lastInsertedIdChanged() |
› Attributes: | Readonly |
query¶
This property holds the query string which will be executed.
› Type: | String |
---|---|
› Signal: | queryChanged() |
› Attributes: | Writable |
Methods¶
Signals¶
Enumerations¶
Error¶
This enumeration describes all errors which can occur in DatabaseSqlQuery objects. The most recently occurred error is stored in the error property.
Name | Value | Description |
---|---|---|
DatabaseSqlQuery.NoError |
0 |
No error occurred or was detected. |
DatabaseSqlQuery.InvalidDatabase |
1 |
Parent is not a database object. |
DatabaseSqlQuery.EmptyQueryError |
2 |
Empty query string. |
DatabaseSqlQuery.InvalidQueryError |
3 |
The query caused an error: . |
DatabaseSqlQuery.TransactionError |
4 |
The query caused an transaction error: . |
DatabaseSqlQuery.UnknownError |
5 |
The query caused an unknown error: . |
Example¶
See LocalDatabase example on how to use DatabaseSqlQuery.