From wiki.ginstr.com
Jump to: navigation, search
(Query that returns specific set of data based on limit and skip parameters)
m (Query with keys and queryType and no limit, skip parameters)
Line 264: Line 264:
 
:<code>ObjektNummer</code> - column name<br>
 
:<code>ObjektNummer</code> - column name<br>
 
:<code>@+id/bebraReport_ObjektNummer</code> - target<br>
 
:<code>@+id/bebraReport_ObjektNummer</code> - target<br>
:<code>@variable/statusFalse,@variable/null</code> - key<br><br>
+
:<code>@variable/statusFalse,@variable/null</code> - key<br>
 
:; ⤷ <code>[gn:act_rawQueryToWidgets]|[bebraObjekte,bebraObjekteDropdownFalseStatus,,,sort;ObjektNummer;@+id/bebraReport_ObjektNummer;@variable/statusFalse,@variable/null]</code>
 
:; ⤷ <code>[gn:act_rawQueryToWidgets]|[bebraObjekte,bebraObjekteDropdownFalseStatus,,,sort;ObjektNummer;@+id/bebraReport_ObjektNummer;@variable/statusFalse,@variable/null]</code>
  

Revision as of 17:58, 24 January 2018

gn:act_rawQueryToWidgets

Description
Action used to query data from database from multiple columns and store value to multiple targets.
Action returns
boolean

Action signatures

Query with keys

[gn:act_rawQueryToWidgets]|[table,query;column{n};target{n};key{n}]
Parameter Description
table table name from which to query data
query query name defined in queries.xml
column{n} table column name from which value will be used
target{n} target where the value from column will be stored
key{n} key to use as values for query

Can be:

Example

assetItems - table name
assetItemsByCode - query name
assetItem_assetNumber,assetItem_nfcTag - column names
@+id/assetItem_assetNumber,@+id/assetItem_nfcTag - target
@+id/assetItem_code - key
[gn:act_rawQueryToWidgets]|[assetItems,assetItemsByCode;assetItem_assetNumber, assetItem_nfcTag;@+id/assetItem_assetNumber,@+id/assetItem_nfcTag;@+id/assetItem_code]
queries.xml
<query 
  id="assetItemsByCode"
  columns="
    assetItem_assetNumber,
    assetItem_code,
    assetItem_nfcTag,
    assetItem_assignment"
  keys="assetItem_code" /> 

Query without keys

[gn:act_rawQueryToWidgets]|[table,query;column{n};target{n}]
Parameter Description
table table name from which to query data
query query name defined in queries.xml
column{n} table column name from which value will be used
target{n} target where the value from column will be stored

Example

users - table name
allUsers - query name
userName,userSurname - column names
@variable/userName,@+id/gnEditTextUserSurname - target
[gn:act_rawQueryToWidgets]|[users,allUsers;userName,userSurname;@variable/userName, @+id/gnEditTextUserSurname]
queries.xml
<query 
  id="allUsers"
  columns=" 
    userName,
    userSurname" />

Query that returns specific set of data based on limit and skip parameters

Please note that you can also use sorting in combination with current skip and limit parameters.

[gn:act_rawQueryToWidgets]|[table,query,limit,skip;column{n};target{n};key{n}]
Parameter Description
table table name from which to query data
query query name defined in queries.xml
limit source value which defines the number of returned rows

Can be:

skip source value which defines the number of skipped rows

Can be:

column{n} table column name from which value will be used
target{n} target where the value from column will be stored
key{n} key to use as values for query

Can be:

Example

bebraObjekte - table name
bebraObjekteDropdownFalseStatus - query name
10 - limit parameter
@+id/skipNumber - skip parameter
ObjektNummer - column name
@+id/bebraReport_ObjektNummer - target
@variable/statusFalse,@variable/null - key
[gn:act_rawQueryToWidgets]|[bebraObjekte,bebraObjekteDropdownFalseStatus,10, @+id/skipNumber;ObjektNummer;@+id/bebraReport_ObjektNummer;@variable/statusFalse,@variable/null]
queries.xml
<query 
  id="bebraObjekteDropdownFalseStatus"
  columns="
    ObjektNummer,
    Status" 
  keys="Status,ObjektNummer"/>

Query with keys and queryType and no limit, skip parameters

[gn:act_rawQueryToWidgets]|[table,query,,,queryType;column{n};target{n};key{n}]
Parameter Description
table table name from which to query data
query query name defined in queries.xml
queryType defines type of query to be executed (See Query types for db queries)
column{n} table column name from which value will be used
target{n} target where the value from column will be stored
key{n} key to use as values for query

Can be:

Example

bebraObjekte - table name
bebraObjekteDropdownFalseStatus - query name
sort - queryType
ObjektNummer - column name
@+id/bebraReport_ObjektNummer - target
@variable/statusFalse,@variable/null - key
[gn:act_rawQueryToWidgets]|[bebraObjekte,bebraObjekteDropdownFalseStatus,,,sort;ObjektNummer;@+id/bebraReport_ObjektNummer;@variable/statusFalse,@variable/null]
queries.xml
<query 
  id="bebraObjekteDropdownFalseStatus"
  columns="
    ObjektNummer,
    Status" 
  keys="Status,ObjektNummer"/>

Query by range

[gn:act_rawQueryToWidgets]|[table,query;column{n};target{n};startKey{n};endKey{n}]
Parameter Description
table table name from which to query data
query query name defined in queries.xml
column{n} table column name from which value will be used
target{n} target where the value from column will be stored
startKey{n} key to use as value for query

Can be:

endKey{n} key to use as value for query

Can be:

Example

notificationTypes - table name
notificationTypesDropdown2 - query name
notificationType_typeOfNotification - column name
@+id/typeOfNotification - target
@variable/value9 - start key
@variable/valueMax - end key
[gn:act_rawQueryToWidgets]|[notificationTypes, notificationTypesDropdown2;notificationType_typeOfNotification;@+id/typeOfNotification;@variable/value9;@variable/valueMax]
queries.xml
<query 
  id="notificationTypesDropdown2" 
  columns="
    notificationType_typeOfNotification,
    notificationType_typeId"
  keys="notificationType_typeId"
/>	

Query types for db queries

Query type Description
regular standard query
sort query that returns all matches sorted i.e. if by timestamp, from earliest to latest.

In queries.xml query keys=”key,key,...,lastKey”, lastkey must be the column by which we want to sort

sortreverse query that returns all matches sorted i.e. if by timestamp, from latest to earliest.

In queries.xml query keys=”key,key,...,lastKey”, lastkey must be the column by which we want to sort

sorttop query that returns single first result and is sorted as per sort query
sortreversetop query that returns single first result and is sorted as per sortreverse query
paging query that returns results with limit and skip, unsorted
count count returns number of matching row results