The Run() method executes the Query you have built using the various SQL-related methods. It must be used as the last method to complete what has been defined as a Query.
… .$Run$( %onDone%, ^onError = null^ );
onDone|Action
The callback function to call when the operation is completed.
The function parameters changes accordingly to the various Run() overrides.
__
onError|(Action< info >)
The callback function to call when a system error occurs.
The function must contain a parameter of Info type which will contain the issue details.
onDone
The onDone parameter is the Action function to call when the operation is completed (the Query has been executed and the UniDB Server App has returned the result of the operation).
Because the various operations methods return different kinds of results, the Run() method has three overrides which cover the possible results scenarios:
1. One Record only
For those methods that return only one Record (SelectOne), you must use this override:
… .$Run$( £< T,£ £info >£ %onDone%, ^onError = null^ );{{{1}}}
2. List of Records
For those methods that may return more Records (Select, SelectRand), you must use this override:
… .$Run$( £< List££<T>,£ £info >£ %onDone%, ^onError = null^ );{{{2}}}
3. Specific information
For those methods that return specific information (Insert, Update, Delete, etc.), you must use this override:
… .$Run$( £< info >£ %onDone%, ^onError = null^ );{{{3}}}
T|Record object
The class which describes a Table’s Record (see the Record class paragraph below).
__
info|Info object
A parameter of type Info that will contain specific information about the operation result.
Record class
For the overrides 1 and 2 of the Run() method, you have to use the Record class of the involved Table. The Record class is defined inside the Unity Settings Script, for each Table. It always has to be called with the following ordinary syntax:
#UniDB#.§database_class§.%table_class%.#Record#
database_class | The class which describes a Database. |
table_class | The class which describes that Database’s Table. |
Info class
The Info class exposes a set of properties for the information returned by some operations methods. Which property will contain specific data depends on the executed operation. For example, methods like Update() and Delete() initialize the affectedRows property, whereas the Insert() method initializes the id property.
Property | Data type | Description | Initialized by |
query | string | The SQL Query string that has been executed. | All |
id | int | The ID of the Record. | Insert() |
affectedRows | int | The number of Records involved in the operation. | Update() Delete() Replace() |
result | float | The numeric result. | Count() Min(), Max() Sum(), Avg() |
exists | bool | Whether the searched Record exists. | Exists() |
error | string | The error message. | All |
status | string | The response status (OK or ERROR) | All |
hasData | bool | True if the response contains data. | All |
isEmpty | bool | True if the response doesn’t contain data. | All |
isOK | bool | True if the response is OK. | All |
isError | bool | True if the response contains an error. | All |
rawData | string | The raw string data received by the UniDB Server App. | All |