Difference between revisions of "Data Mapping"

From Lianjapedia
Jump to: navigation, search
Line 25: Line 25:
 
</code>
 
</code>
  
 
+
Both the '''Get data mapping''' and the '''Set data mapping''' in this example use the [[KEYLOOKUP()]] function.
 +
<pre>
 +
KEYLOOKUP(<workarea | alias | table>, <"indextagname">, <keyExpr>, <valueExpr> [, <notfoundExpr>])
 +
</pre>
  
 
Get data mapping:
 
Get data mapping:
Line 31: Line 34:
 
keylookup("products", "productid", {}, productname)
 
keylookup("products", "productid", {}, productname)
 
</code>
 
</code>
 
<pre>
 
KEYLOOKUP(<workarea | alias | table>, <"indextagname">, <keyExpr>, <valueExpr> [, <notfoundExpr>])
 
</pre>
 
  
 
{| class="wikitable" width="100%"
 
{| class="wikitable" width="100%"
Line 48: Line 47:
 
|valign="top"|productname||The value expression to return if the key value is found in the index.  So, in this case, if the value of the current order_details.productid is found in the products table productid index, the products.productname value will be returned for the corresponding record.
 
|valign="top"|productname||The value expression to return if the key value is found in the index.  So, in this case, if the value of the current order_details.productid is found in the products table productid index, the products.productname value will be returned for the corresponding record.
 
|-
 
|-
|valign="top"|-||An optional 'not found' expression can also be specified.  If the key value is not found in the index, this will be returned, e.g. "Product not found".
+
|valign="top"|-||An optional 'not found' expression can also be specified.  If the key value is not found in the index, this will be returned.  This should be the same data type as the 'value' expression, the character products.productname here, e.g. "Product not found".
 
|}
 
|}
  
Line 55: Line 54:
 
keylookup("products", "productname", "{}", productid)
 
keylookup("products", "productname", "{}", productid)
 
</code>
 
</code>
 +
 +
{| class="wikitable" width="100%"
 +
!width="15%"|Argument
 +
!width="85%"|Description
 +
|-
 +
|valign="top"|"products"||The name of the lookup table (in quotes).<br>Alternatively, the alias name (in quotes) or workarea number (no quotes) can be specified if the lookup table is open. 
 +
|-
 +
|valign="top"|"productname"||The name of the index tag (in quotes) for the lookup table to search.  Index tags can be created using the [[INDEX|index on]] command.
 +
|-
 +
|valign="top"|{}||The key value expression to search for in the index.  In this case, we are looking for the character value of the mapped cell contents in the current row of the Grid Section, so we can use ''''{}''''.  For a numeric value, no quotes are required '''{}'''.
 +
|-
 +
|valign="top"|productid||The value expression to return if the key value is found in the index.  So, in this case, if the value of the current cell is found in the products table productname index, the products.productid value will be returned for the corresponding record.
 +
|-
 +
|valign="top"|-||An optional 'not found' expression can also be specified.  If the key value is not found in the index, this will be returned.  This should be the same data type as the 'value' expression, the numeric products.producid here, e.g. 0.
 +
|}

Revision as of 10:04, 3 February 2015

Under construction

See Also

INDEX, KEYLOOKUP(), SQL SELECT

Example Data Mapping App

example_datamapping

Example Data Mapping app: example_datamapping


Choice list


Attributes


Choices:

select productname from products order by productname

Both the Get data mapping and the Set data mapping in this example use the KEYLOOKUP() function.

KEYLOOKUP(<workarea | alias | table>, <"indextagname">, <keyExpr>, <valueExpr> [, <notfoundExpr>])

Get data mapping:

keylookup("products", "productid", {}, productname)
Argument Description
"products" The name of the lookup table (in quotes).
Alternatively, the alias name (in quotes) or workarea number (no quotes) can be specified if the lookup table is open.
"productid" The name of the index tag (in quotes) for the lookup table to search. Index tags can be created using the index on command.
{} The key value expression to search for in the index. In this case, we are looking for the numeric value of the order_details.productid field in the current row of the Grid Section, so we can use {}. For a character value, quotes are required '{}'.
productname The value expression to return if the key value is found in the index. So, in this case, if the value of the current order_details.productid is found in the products table productid index, the products.productname value will be returned for the corresponding record.
- An optional 'not found' expression can also be specified. If the key value is not found in the index, this will be returned. This should be the same data type as the 'value' expression, the character products.productname here, e.g. "Product not found".

Set data mapping:

keylookup("products", "productname", "{}", productid)
Argument Description
"products" The name of the lookup table (in quotes).
Alternatively, the alias name (in quotes) or workarea number (no quotes) can be specified if the lookup table is open.
"productname" The name of the index tag (in quotes) for the lookup table to search. Index tags can be created using the index on command.
{} The key value expression to search for in the index. In this case, we are looking for the character value of the mapped cell contents in the current row of the Grid Section, so we can use '{}'. For a numeric value, no quotes are required {}.
productid The value expression to return if the key value is found in the index. So, in this case, if the value of the current cell is found in the products table productname index, the products.productid value will be returned for the corresponding record.
- An optional 'not found' expression can also be specified. If the key value is not found in the index, this will be returned. This should be the same data type as the 'value' expression, the numeric products.producid here, e.g. 0.