1. Home
  2. Docs
  3. UniDB 1.2
  4. UniDB class
  5. Run

Run

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_classThe class which describes a Database.
table_classThe 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.

PropertyData typeDescriptionInitialized by
querystringThe SQL Query string that has been executed.All
idintThe ID of the Record.Insert()
affectedRowsintThe number of Records involved in the operation.Update()
Delete()
Replace()
resultfloatThe numeric result.Count()
Min(), Max()
Sum(), Avg()
existsboolWhether the searched Record exists.Exists()
errorstringThe error message.All
statusstringThe response status (OK or ERROR)All
hasDataboolTrue if the response contains data.All
isEmptyboolTrue if the response doesn’t contain data.All
isOKboolTrue if the response is OK.All
isErrorboolTrue if the response contains an error.All
rawDatastringThe raw string data received by the UniDB Server App.All