From wiki.ginstr.com
Jump to: navigation, search
m (formatting)
Line 11: Line 11:
 
===Query with keys===
 
===Query with keys===
  
;<code>[gn:act_rawQueryToWidget]|[table,query,column,target;key{n}]</code>
+
:;<code>[gn:act_rawQueryToWidget]|[table,query,column,target;key{n}]</code>
  
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
+
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
 
! scope="col" | Parameter
 
! scope="col" | Parameter
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| table
+
| <code>table</code>
 
| table name from which to query data
 
| table name from which to query data
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| query
+
| <code>query</code>
 
| query name defined in queries.xml
 
| query name defined in queries.xml
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| column
+
| <code>column</code>
 
| table column name from which value will be used
 
| table column name from which value will be used
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| [[target]]
+
| <code>[[target]]</code>
 
| [[target]] where the value from column will be stored
 
| [[target]] where the value from column will be stored
 
* Valid [[target|targets]]:
 
* Valid [[target|targets]]:
 
** any [[target]]
 
** any [[target]]
 
|-
 
|-
| key{n}
+
| <code>key{n}</code>
 
| key to use as values for query
 
| key to use as values for query
 
Can be:
 
Can be:
* [[Datatypes#text|text]]
+
* <code>[[Datatypes#text|text]]</code>
* [[Datatypes#number|number]]
+
* <code>[[Datatypes#number|number]]</code>
* [[Datatypes#status|status]]
+
* <code>[[Datatypes#status|status]]</code>
* [[Datatypes#dateTime|dateTime]]
+
* <code>[[Datatypes#dateTime|dateTime]]</code>
* [[Datatypes#pointer|pointer]]
+
* <code>[[Datatypes#pointer|pointer]]</code>
* [[Datatypes#assignment|assignment]]
+
* <code>[[Datatypes#assignment|assignment]]</code>
* [[Datatypes#date|date]]
+
* <code>[[Datatypes#date|date]]</code>
* [[Datatypes#time|time]]
+
* <code>[[Datatypes#time|time]]</code>
* [[Datatypes#counter|counter]]
+
* <code>[[Datatypes#counter|counter]]</code>
* [[Datatypes#rowsColumn|rowsColumn]]
+
* <code>[[Datatypes#rowsColumn|rowsColumn]]</code>
 
|-
 
|-
 
|}
 
|}
  
 
====Example====
 
====Example====
 +
:<code>locations</code> - table name<br>
 +
:<code>locationsByName</code> - query name<br>
 +
:<code>location_name</code> - column name<br>
 +
:<code>@+id/location_name</code> - target<br>
 +
:<code>@+id/location_name</code> - key<br>
 +
:; ⤷ <code>[gn:act_rawQueryToWidget]|[locations,locationsByName,location_name,@+id/location_name;@+id/location_name]</code>
 +
 
=====queries.xml=====
 
=====queries.xml=====
 
<SyntaxHighlight lang="xml">
 
<SyntaxHighlight lang="xml">
Line 61: Line 68:
 
   keys="location_name" />
 
   keys="location_name" />
 
</SyntaxHighlight>
 
</SyntaxHighlight>
=====code=====
+
 
<code>locations</code> - table name<br>
 
<code>locationsByName</code> - query name<br>
 
<code>location_name</code> - column name<br>
 
<code>@+id/location_name</code> - target<br>
 
<code>@+id/location_name</code> - key<br><br>
 
<code>[gn:act_rawQueryToWidget]|[locations,locationsByName,location_name,@+id/location_name;@+id/location_name]</code>
 
 
<hr>
 
<hr>
 
 
===Query without keys===
 
===Query without keys===
  
;<code>[gn:act_rawQueryToWidget]|[table,query,column,target]</code>
+
:;<code>[gn:act_rawQueryToWidget]|[table,query,column,target]</code>
  
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
+
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
 
! scope="col" | Parameter
 
! scope="col" | Parameter
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| table
+
| <code>table</code>
 
| table name from which to query data
 
| table name from which to query data
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| query
+
| <code>query</code>
 
| query name defined in queries.xml
 
| query name defined in queries.xml
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| column
+
| <code>column</code>
 
| table column name from which value will be used
 
| table column name from which value will be used
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| [[target]]
+
| <code>[[target]]</code>
 
| [[target]] where the value from column will be stored
 
| [[target]] where the value from column will be stored
 
* Valid [[target|targets]]:
 
* Valid [[target|targets]]:
Line 102: Line 102:
  
 
====Example====
 
====Example====
 +
:<code>services</code> - table name<br>
 +
:<code>services</code> - query name<br>
 +
:<code>service_name</code> - column name<br>
 +
:<code>@+id/service_name</code> - target<br>
 +
:; ⤷ <code>[gn:act_rawQueryToWidget]|[services,services,service_name,@+id/service_name]</code>
 +
 
=====queries.xml=====
 
=====queries.xml=====
 
<SyntaxHighlight lang="xml">
 
<SyntaxHighlight lang="xml">
Line 110: Line 116:
 
     service_comments" />
 
     service_comments" />
 
</SyntaxHighlight>
 
</SyntaxHighlight>
=====code=====
+
 
<code>services</code> - table name<br>
 
<code>services</code> - query name<br>
 
<code>service_name</code> - column name<br>
 
<code>@+id/service_name</code> - target<br><br>
 
<code>[gn:act_rawQueryToWidget]|[services,services,service_name,@+id/service_name]</code>
 
 
<hr>
 
<hr>
  
 
===Query without target to check if some record exists===
 
===Query without target to check if some record exists===
  
;<code>[gn:act_rawQueryToWidget]|[table,query,column;key{n}]</code>
+
:;<code>[gn:act_rawQueryToWidget]|[table,query,column;key{n}]</code>
  
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
+
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
 
! scope="col" | Parameter
 
! scope="col" | Parameter
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| table
+
| <code>table</code>
 
| table name from which to query data
 
| table name from which to query data
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| query
+
| <code>query</code>
 
| query name defined in queries.xml
 
| query name defined in queries.xml
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| column
+
| <code>column</code>
 
| table column name from which value will be used
 
| table column name from which value will be used
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| key{n}
+
| <code>key{n}</code>
 
| key to use as values for query
 
| key to use as values for query
 
Can be:
 
Can be:
* [[Datatypes#text|text]]
+
* <code>[[Datatypes#text|text]]</code>
* [[Datatypes#number|number]]
+
* <code>[[Datatypes#number|number]]</code>
* [[Datatypes#status|status]]
+
* <code>[[Datatypes#status|status]]</code>
* [[Datatypes#dateTime|dateTime]]
+
* <code>[[Datatypes#dateTime|dateTime]]</code>
* [[Datatypes#pointer|pointer]]
+
* <code>[[Datatypes#pointer|pointer]]</code>
* [[Datatypes#assignment|assignment]]
+
* <code>[[Datatypes#assignment|assignment]]</code>
* [[Datatypes#date|date]]
+
* <code>[[Datatypes#date|date]]</code>
* [[Datatypes#time|time]]
+
* <code>[[Datatypes#time|time]]</code>
* [[Datatypes#counter|counter]]
+
* <code>[[Datatypes#counter|counter]]</code>
* [[Datatypes#rowsColumn|rowsColumn]]
+
* <code>[[Datatypes#rowsColumn|rowsColumn]]</code>
 
|-
 
|-
 
|}
 
|}
  
 
====Example====
 
====Example====
 +
:<code>assetItems</code> - table name<br>
 +
:<code>assetItemsByCode</code> - query name<br>
 +
:<code>assetItem_nfcTag</code> - column name<br>
 +
:<code>@+id/assetItem_code</code> - key<br>
 +
:; ⤷ <code>[gn:act_rawQueryToWidget]|[assetItems,assetItemsByCode,assetItem_nfcTag;@+id/assetItem_code]</code>
 +
 
=====queries.xml=====
 
=====queries.xml=====
 
<SyntaxHighlight lang="xml">
 
<SyntaxHighlight lang="xml">
Line 171: Line 178:
 
</SyntaxHighlight>
 
</SyntaxHighlight>
  
=====code=====
 
<code>assetItems</code> - table name<br>
 
<code>assetItemsByCode</code> - query name<br>
 
<code>assetItem_nfcTag</code> - column name<br>
 
<code>@+id/assetItem_code</code> - key<br><br>
 
<code>[gn:act_rawQueryToWidget]|[assetItems,assetItemsByCode,assetItem_nfcTag;@+id/assetItem_code]</code>
 
 
<hr>
 
<hr>
  
 
===Query without column that stores entire result to targets that accept multiple rows===
 
===Query without column that stores entire result to targets that accept multiple rows===
  
;<code>[gn:act_rawQueryToWidget]|[table,query,,target;key{n}]</code>
+
:;<code>[gn:act_rawQueryToWidget]|[table,query,,target;key{n}]</code>
  
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
+
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
 
! scope="col" | Parameter
 
! scope="col" | Parameter
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| table
+
| <code>table</code>
 
| table name from which to query data
 
| table name from which to query data
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| query
+
| <code>query</code>
 
| query name defined in queries.xml
 
| query name defined in queries.xml
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| [[target]]
+
| <code>[[target]]</code>
 
| [[target]] where the value from column will be stored
 
| [[target]] where the value from column will be stored
 
* Valid [[target|targets]]:
 
* Valid [[target|targets]]:
 
** any [[target]]
 
** any [[target]]
 
|-
 
|-
| key{n}
+
| <code>key{n}</code>
 
| key to use as values for query
 
| key to use as values for query
 
Can be:
 
Can be:
* [[Datatypes#text|text]]
+
* <code>[[Datatypes#text|text]]</code>
* [[Datatypes#number|number]]
+
* <code>[[Datatypes#number|number]]</code>
* [[Datatypes#status|status]]
+
* <code>[[Datatypes#status|status]]</code>
* [[Datatypes#dateTime|dateTime]]
+
* <code>[[Datatypes#dateTime|dateTime]]</code>
* [[Datatypes#pointer|pointer]]
+
* <code>[[Datatypes#pointer|pointer]]</code>
* [[Datatypes#assignment|assignment]]
+
* <code>[[Datatypes#assignment|assignment]]</code>
* [[Datatypes#date|date]]
+
* <code>[[Datatypes#date|date]]</code>
* [[Datatypes#time|time]]
+
* <code>[[Datatypes#time|time]]</code>
* [[Datatypes#counter|counter]]
+
* <code>[[Datatypes#counter|counter]]</code>
* [[Datatypes#rowsColumn|rowsColumn]]
+
* <code>[[Datatypes#rowsColumn|rowsColumn]]</code>
 
|-
 
|-
 
|}
 
|}
  
 
====Example====
 
====Example====
 +
:<code>bebraTimeRecordingbokings</code> - table name<br>
 +
:<code>bebraTimeRecordingbokingsByConstructionSiteAndActive</code> - query name<br>
 +
:<code>-</code> - all columns<br>
 +
:<code>@+id/lstSite</code> - target<br>
 +
:<code>@+id/bebraTimeRecording_constructionSite,@variable/true</code> - keys<br>
 +
:; ⤷ <code>[gn:act_rawQueryToWidget]|[bebraTimeRecordingbokings,bebraTimeRecordingbokingsByConstructionSiteAndActive,-, @+id/lstSite;@+id/bebraTimeRecording_constructionSite,@variable/true]</code>
 
=====queries.xml=====
 
=====queries.xml=====
 
<SyntaxHighlight lang="xml">
 
<SyntaxHighlight lang="xml">
Line 240: Line 247:
 
</SyntaxHighlight>
 
</SyntaxHighlight>
  
=====code=====
 
<code>bebraTimeRecordingbokings</code> - table name<br>
 
<code>bebraTimeRecordingbokingsByConstructionSiteAndActive</code> - query name<br>
 
<code>-</code> - all columns<br>
 
<code>@+id/lstSite</code> - target<br>
 
<code>@+id/bebraTimeRecording_constructionSite,@variable/true</code> - keys<br><br>
 
<code>[gn:act_rawQueryToWidget]|[bebraTimeRecordingbokings,bebraTimeRecordingbokingsByConstructionSiteAndActive,-,@+id/lstSite;@+id/bebraTimeRecording_constructionSite,@variable/true]</code>
 
 
<hr>
 
<hr>
  
===Query with multiple keys and queryType defined===
+
===Query with multiple keys and <code>queryType</code> defined===
  
;<code>[gn:act_rawQueryToWidget]|[table,query,column,target,queryType;key{n}]</code>
+
:;<code>[gn:act_rawQueryToWidget]|[table,query,column,target,queryType;key{n}]</code>
  
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
+
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
 
! scope="col" | Parameter
 
! scope="col" | Parameter
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| table
+
| <code>table</code>
 
| table name from which to query data
 
| table name from which to query data
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| query
+
| <code>query</code>
 
| query name defined in queries.xml
 
| query name defined in queries.xml
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| column
+
| <code>column</code>
 
| table column name from which value will be used
 
| table column name from which value will be used
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| [[target]]
+
| <code>[[target]]</code>
 
| [[target]] where the value from column will be stored
 
| [[target]] where the value from column will be stored
 
* Valid [[target|targets]]:
 
* Valid [[target|targets]]:
 
** any [[target]]
 
** any [[target]]
 
|-
 
|-
| queryType
+
| <code>queryType</code>
 
| defines type of query to be executed (See [[#Query_types_for_db_queries|Query types for db queries]])
 
| defines type of query to be executed (See [[#Query_types_for_db_queries|Query types for db queries]])
 
|-
 
|-
| key{n}
+
| <code>key{n}</code>
 
| key to use as values for query
 
| key to use as values for query
 
Can be:
 
Can be:
* [[Datatypes#text|text]]
+
* <code>[[Datatypes#text|text]]</code>
* [[Datatypes#number|number]]
+
* <code>[[Datatypes#number|number]]</code>
* [[Datatypes#status|status]]
+
* <code>[[Datatypes#status|status]]</code>
* [[Datatypes#dateTime|dateTime]]
+
* <code>[[Datatypes#dateTime|dateTime]]</code>
* [[Datatypes#pointer|pointer]]
+
* <code>[[Datatypes#pointer|pointer]]</code>
* [[Datatypes#assignment|assignment]]
+
* <code>[[Datatypes#assignment|assignment]]</code>
* [[Datatypes#date|date]]
+
* <code>[[Datatypes#date|date]]</code>
* [[Datatypes#time|time]]
+
* <code>[[Datatypes#time|time]]</code>
* [[Datatypes#counter|counter]]
+
* <code>[[Datatypes#counter|counter]]</code>
* [[Datatypes#rowsColumn|rowsColumn]]
+
* <code>[[Datatypes#rowsColumn|rowsColumn]]</code>
 
|-
 
|-
 
|}
 
|}
  
 
====Example====
 
====Example====
<code>users</code> - table name<br>
+
:<code>users</code> - table name<br>
<code>userById</code> - query name<br>
+
:<code>userById</code> - query name<br>
<code>username</code> - column name<br>
+
:<code>username</code> - column name<br>
<code>@+id/gnEditTextName</code> - [[target]]<br>
+
:<code>@+id/gnEditTextName</code> - [[target]]<br>
<code>sorttop</code> - queryType<br>
+
:<code>sorttop</code> - queryType<br>
<code>@variable/userId,@variable/userName</code> - key<br><br>
+
:<code>@variable/userId,@variable/userName</code> - key<br>
<code>[gn:act_rawQueryToWidget]|[users,userById,username,@+id/gnEditTextName,sorttop;@variable/userId,@variable/userName]</code>
+
:; ⤷ <code>[gn:act_rawQueryToWidget]|[users,userById,username,@+id/gnEditTextName, sorttop;@variable/userId,@variable/userName]</code>
 
<hr>
 
<hr>
  
===Query with multiple keys and queryType defined, where the keys are split by SPLITKEYVALUES===
+
===Query with multiple keys and <code>queryType</code> defined, where the keys are split by <code>SPLITKEYVALUES</code>===
  
 
;<code>[gn:act_rawQueryToWidget]|[table,query,-,target,queryType,viewType;key{n}]</code>
 
;<code>[gn:act_rawQueryToWidget]|[table,query,-,target,queryType,viewType;key{n}]</code>
Line 316: Line 316:
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| table
+
| <code>table</code>
 
| table name from which to query data
 
| table name from which to query data
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| query
+
| <code>query</code>
 
| query name defined in queries.xml
 
| query name defined in queries.xml
 
* Valid [[source|sources]]:
 
* Valid [[source|sources]]:
 
** hardcoded value
 
** hardcoded value
 
|-
 
|-
| [[target]]
+
| <code>[[target]]</code>
 
| [[target]] where the value from column will be stored
 
| [[target]] where the value from column will be stored
 
* Valid [[target|targets]]:
 
* Valid [[target|targets]]:
 
** any [[target]]
 
** any [[target]]
 
|-
 
|-
| queryType
+
| <code>queryType</code>
 
| defines type of query to be executed (See [[#Query_types_for_db_queries|Query types for db queries]])
 
| defines type of query to be executed (See [[#Query_types_for_db_queries|Query types for db queries]])
 
|-
 
|-
| viewType
+
| <code>viewType</code>
 
| used for special purpose
 
| used for special purpose
 
Can be:
 
Can be:
 
* <code>SPLIKEYVALUES</code> - used to notify this action to split each key value by <code> </code> or <code>,</code> and to execute queries for each split key
 
* <code>SPLIKEYVALUES</code> - used to notify this action to split each key value by <code> </code> or <code>,</code> and to execute queries for each split key
 
|-
 
|-
| key{n}
+
| <code>key{n}</code>
 
| key to use as values for query
 
| key to use as values for query
 
Can be:
 
Can be:
* [[Datatypes#text|text]]
+
* <code>[[Datatypes#text|text]]</code>
* [[Datatypes#number|number]]
+
* <code>[[Datatypes#number|number]]</code>
* [[Datatypes#status|status]]
+
* <code>[[Datatypes#status|status]]</code>
* [[Datatypes#dateTime|dateTime]]
+
* <code>[[Datatypes#dateTime|dateTime]]</code>
* [[Datatypes#pointer|pointer]]
+
* <code>[[Datatypes#pointer|pointer]]</code>
* [[Datatypes#assignment|assignment]]
+
* <code>[[Datatypes#assignment|assignment]]</code>
* [[Datatypes#date|date]]
+
* <code>[[Datatypes#date|date]]</code>
* [[Datatypes#time|time]]
+
* <code>[[Datatypes#time|time]]</code>
* [[Datatypes#counter|counter]]
+
* <code>[[Datatypes#counter|counter]]</code>
* [[Datatypes#rowsColumn|rowsColumn]]
+
* <code>[[Datatypes#rowsColumn|rowsColumn]]</code>
 
|-
 
|-
 
|}
 
|}
  
 
====Example====
 
====Example====
 +
:<code>Drivers</code> - table name<br>
 +
:<code>driversByFirstAndLastName</code> - query name<br>
 +
:<code>-</code> - all columns<br>
 +
:<code>+id/lstDriversNoSub</code> - target<br>
 +
:<code>regular</code> - queryType<br>
 +
:<code>SPLITKEYVALUES</code> - viewType<br>
 +
:<code>+id/Driver_firstAndLastName</code> - key<br>
 +
:; ⤷ <code>[gn:act_rawQueryToWidget]|[Drivers,driversByFirstAndLastName,-,@+id/lstDriversNoSub,regular,SPLITKEYVALUES;@+id/Driver_firstAndLastName]</code>
 +
 
=====queries.xml=====
 
=====queries.xml=====
 
<SyntaxHighlight lang="xml">
 
<SyntaxHighlight lang="xml">
Line 370: Line 379:
 
</SyntaxHighlight>
 
</SyntaxHighlight>
  
=====code=====
 
<code>Drivers</code> - table name<br>
 
<code>driversByFirstAndLastName</code> - query name<br>
 
<code>-</code> - all columns<br>
 
<code>+id/lstDriversNoSub</code> - target<br>
 
<code>regular</code> - queryType<br>
 
<code>SPLITKEYVALUES</code> - viewType<br>
 
<code>+id/Driver_firstAndLastName</code> - key<br><br>
 
<code>[gn:act_rawQueryToWidget]|[Drivers,driversByFirstAndLastName,-,@+id/lstDriversNoSub,regular,SPLITKEYVALUES;@+id/Driver_firstAndLastName]</code>
 
 
<hr>
 
<hr>
  
Line 384: Line 384:
 
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
! scope="col" | Query type
+
! scope="col" | <code>queryType</code>
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| regular
+
| <code>regular</code>
 
| standard query
 
| standard query
 
|-
 
|-
| sort
+
| <code>sort</code>
 
| query that returns all matches sorted i.e. if by <code>timestamp</code>, from earliest to latest.  
 
| query that returns all matches sorted i.e. if by <code>timestamp</code>, from earliest to latest.  
 
In [[Database#queries.xml|queries.xml]] query <code>keys=”key,key,...,lastKey”</code>, <code>lastkey</code> must be the column by which we want to sort
 
In [[Database#queries.xml|queries.xml]] query <code>keys=”key,key,...,lastKey”</code>, <code>lastkey</code> must be the column by which we want to sort
 
|-
 
|-
| sortreverse
+
| <code>sortreverse</code>
 
| query that returns all matches sorted i.e. if by <code>timestamp</code>, from latest to earliest.  
 
| query that returns all matches sorted i.e. if by <code>timestamp</code>, from latest to earliest.  
 
In [[Database#queries.xml|queries.xml]] query <code>keys=”key,key,...,lastKey”</code>, <code>lastkey</code> must be the column by which we want to sort
 
In [[Database#queries.xml|queries.xml]] query <code>keys=”key,key,...,lastKey”</code>, <code>lastkey</code> must be the column by which we want to sort
 
|-
 
|-
| sorttop
+
| <code>sorttop</code>
 
| query that returns single first result and is sorted like <code>sort</code> query
 
| query that returns single first result and is sorted like <code>sort</code> query
 
|-
 
|-
| sortreversetop
+
| <code>sortreversetop</code>
 
| query that returns single first result and is sorted like <code>sortreverse</code> query
 
| query that returns single first result and is sorted like <code>sortreverse</code> query
 
|-
 
|-
| paging
+
| <code>paging</code>
 
| query that returns results with <code>limit</code> and <code>skip</code>, unsorted
 
| query that returns results with <code>limit</code> and <code>skip</code>, unsorted
 
|-
 
|-
| count
+
| <code>count</code>
 
| count returns number of matching row results
 
| count returns number of matching row results
 
|-
 
|-
 
|}
 
|}

Revision as of 15:22, 12 July 2017

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
query query name defined in queries.xml
column table column name from which value will be used
target target where the value from column will be stored
key{n} key to use as values for query

Can be:

Example

locations - table name
locationsByName - query name
location_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
query query name defined in queries.xml
column table column name from which value will be used
target target where the value from column will be stored

Example

services - table name
services - query name
service_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
query query name defined in queries.xml
column table column name from which value will be used
key{n} key to use as values for query

Can be:

Example

assetItems - table name
assetItemsByCode - query name
assetItem_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
query query name defined in queries.xml
target target where the value from column will be stored
key{n} key to use as values for query

Can be:

Example

bebraTimeRecordingbokings - table name
bebraTimeRecordingbokingsByConstructionSiteAndActive - 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
query query name defined in queries.xml
column table column name from which value will be used
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:

Example

users - table name
userById - query name
username - column name
@+id/gnEditTextName - target
sorttop - 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
query query name defined in queries.xml
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 or , and to execute queries for each split key
key{n} key to use as values for query

Can be:

Example

Drivers - table name
driversByFirstAndLastName - query name
- - all columns
+id/lstDriversNoSub - target
regular - queryType
SPLITKEYVALUES - 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 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 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