General SQL syntax
A simple SQL query:
select <ValueField>, <DisplayField>
from <Table>
where <Some Condition>
The first column must be the value for the list item and the second column the display for the list item.
A select statement can also return a single column:
select <ValueField>
from <Table>
where <Some Condition>
In this example, the column will be used for both the value and display for the list item.
A conditional select statement:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” = ‘Fred’
In this example, all customers where Customer Name is “Fred” will be returned.
A conditional select statement using wildcard symbols:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” like ‘%Johnson’
In this example, all customers where Customer Name ends with the text “Johnson” will be returned. For example, customers where Customer Name is “FJohnson”, “FredJohnson”, “Johnson” or “3Johnson” will be returned.
SQL wildcard syntax is used with the like operator. The wildcard “_” is used to specify a wildcard for one character. The wildcard “%” is used to specify a wildcard for one or more character.
Using a RRT pattern in a conditional select statement:
It is possible to use a RRT pattern in a conditional select statement if field values are entered by the user from the Workflow form.
RRT pattern takes the following format: ~RCH::%FieldName%~.
It is important to note that the “%” symbol used with RRT patterns does not function like the “%” symbol used for wildcard based searches. With RRT patterns, the entire RRT pattern will be replaced with the field value that was entered by the user from the Workflow form.
Example:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” like ‘~RCH::%Customer%~’
In this example, the AutoStore form has the RRT pattern patternFld. Once a user enters a value for patternFld, then ~RCH::%patternFld%~ will get replaced with the value of patternFld.
If the user entered “Johnson” at the MFP for patternFld, the resulting query would be:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” like ‘Johnson’
Note that RRT patterns within SQL select statements can be used with other SQL syntax such as wildcard characters. The following would be a valid SQL statement:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” like ‘%~RCH::%patternFld%~%’