Contents
- 1 Action signatures
- 1.1 Query with keys
- 1.2 Query without keys
- 1.3 Query without target to check if some record exists
- 1.4 Query without column that stores entire result to targets that accept multiple rows
- 1.5 Query with multiple keys and queryType defined
- 1.6 Query with multiple keys and queryType defined, where the keys are split by SPLITKEYVALUES
- 2 Query types for db queries
gn:act_rawQueryToWidget
- Description
- Action used to query data from database and store value to a target.
- Action returns
- boolean
Action signatures
Query with keys
[gn:act_rawQueryToWidget]|[table,query,column,target;key{n}]
Parameter Description table
table name from which to query data - Valid sources:
- hardcoded value
query
query name defined in queries.xml - Valid sources:
- hardcoded value
column
table column name from which value will be used - Valid sources:
- hardcoded value
target
target where the value from column will be stored key{n}
key to use as values for query Can be:
- Valid sources:
Example
locations
- table namelocationsByName
- query namelocation_name
- column name@+id/location_name
- target@+id/location_name
- key
- ⤷
[gn:act_rawQueryToWidget]|[locations,locationsByName,location_name,@+id/location_name;@+id/location_name]
- ⤷
queries.xml
<query id="locationsByName" columns="location_name" keys="location_name" />
Query without keys
[gn:act_rawQueryToWidget]|[table,query,column,target]
Parameter Description table
table name from which to query data - Valid sources:
- hardcoded value
query
query name defined in queries.xml - Valid sources:
- hardcoded value
column
table column name from which value will be used - Valid sources:
- hardcoded value
target
target where the value from column will be stored - Valid sources:
Example
services
- table nameservices
- query nameservice_name
- column name@+id/service_name
- target
- ⤷
[gn:act_rawQueryToWidget]|[services,services,service_name,@+id/service_name]
- ⤷
queries.xml
<query id="services" columns=" service_name, service_comments" />
Query without target to check if some record exists
[gn:act_rawQueryToWidget]|[table,query,column;key{n}]
Parameter Description table
table name from which to query data - Valid sources:
- hardcoded value
query
query name defined in queries.xml - Valid sources:
- hardcoded value
column
table column name from which value will be used - Valid sources:
- hardcoded value
key{n}
key to use as values for query Can be:
- Valid sources:
Example
assetItems
- table nameassetItemsByCode
- query nameassetItem_nfcTag
- column name@+id/assetItem_code
- key
- ⤷
[gn:act_rawQueryToWidget]|[assetItems,assetItemsByCode,assetItem_nfcTag;@+id/assetItem_code]
- ⤷
queries.xml
<query id="assetItemsByCode" columns=" assetItem_assetNumber, assetItem_code, assetItem_nfcTag, assetItem_assignment" keys="assetItem_code" />
Query without column that stores entire result to targets that accept multiple rows
[gn:act_rawQueryToWidget]|[table,query,,target;key{n}]
Parameter Description table
table name from which to query data - Valid sources:
- hardcoded value
query
query name defined in queries.xml - Valid sources:
- hardcoded value
target
target where the value from column will be stored key{n}
key to use as values for query Can be:
- Valid sources:
Example
bebraTimeRecordingbokings
- table namebebraTimeRecordingbokingsByConstructionSiteAndActive
- query name-
- all columns@+id/lstSite
- target@+id/bebraTimeRecording_constructionSite,@variable/true
- keys
- ⤷
[gn:act_rawQueryToWidget]|[bebraTimeRecordingbokings,bebraTimeRecordingbokingsByConstructionSiteAndActive,-, @+id/lstSite;@+id/bebraTimeRecording_constructionSite,@variable/true]
- ⤷
queries.xml
<query id="bebraTimeRecordingbokingsByConstructionSiteAndActive" columns=" nfc, user, name, surname, personellnum, comment, userlocation, deviceSerial, timestamp, timestampEnd, workingTimeInHours, constructionSite,active" keys="constructionSite,active" />
Query with multiple keys and queryType
defined
[gn:act_rawQueryToWidget]|[table,query,column,target,queryType;key{n}]
Parameter Description table
table name from which to query data - Valid sources:
- hardcoded value
query
query name defined in queries.xml - Valid sources:
- hardcoded value
column
table column name from which value will be used - Valid sources:
- hardcoded value
target
target where the value from column will be stored queryType
defines type of query to be executed (See Query types for db queries) key{n}
key to use as values for query Can be:
- Valid sources:
Example
users
- table nameuserById
- query nameusername
- column name@+id/gnEditTextName
- targetsorttop
- queryType@variable/userId,@variable/userName
- key
- ⤷
[gn:act_rawQueryToWidget]|[users,userById,username,@+id/gnEditTextName, sorttop;@variable/userId,@variable/userName]
- ⤷
Query with multiple keys and queryType
defined, where the keys are split by SPLITKEYVALUES
[gn:act_rawQueryToWidget]|[table,query,-,target,queryType,viewType;key{n}]
Parameter Description table
table name from which to query data - Valid sources:
- hardcoded value
query
query name defined in queries.xml - Valid sources:
- hardcoded value
target
target where the value from column will be stored queryType
defines type of query to be executed (See Query types for db queries) viewType
used for special purpose Can be:
SPLIKEYVALUES
- used to notify this action to split each key value by,
and to execute queries for each split key
key{n}
key to use as values for query Can be:
- Valid sources:
Example
Drivers
- table namedriversByFirstAndLastName
- query name-
- all columns+id/lstDriversNoSub
- targetregular
- queryTypeSPLITKEYVALUES
- viewType+id/Driver_firstAndLastName
- key
- ⤷
[gn:act_rawQueryToWidget]|[Drivers,driversByFirstAndLastName,-,@+id/lstDriversNoSub,regular,SPLITKEYVALUES;@+id/Driver_firstAndLastName]
- ⤷
queries.xml
<query id="driversByFirstAndLastName" columns=" Driver_firstName, Driver_lastName, Driver_firstAndLastName, Driver_comments, Driver_subName" type="INDEX" keys="Driver_firstName,Driver_lastName" />
Query types for db queries
queryType
|
Description |
---|---|
regular
|
standard query |
sort
|
query that returns all matches sorted i.e. if by timestamp , from earliest to latest.
In queries.xml query |
sortreverse
|
query that returns all matches sorted i.e. if by timestamp , from latest to earliest.
In queries.xml query |
sorttop
|
query that returns single first result and is sorted like sort query
|
sortreversetop
|
query that returns single first result and is sorted like sortreverse query
|
paging
|
query that returns results with limit and skip , unsorted
|
count
|
count returns number of matching row results |