9.5.3 Multi-value SQL Parameters | |
Normally SQL parameters are single-value variables, as in our patent example.
However, if a multi-value string parameter is passed, it is concatenated into a parenthetical, comma-separated list before being passed to the SQL engine. This enables a list of words to be easily OR-searched, as a parenthetical comma-separated list is a set of equivalent terms in Metamorph:
<$list = "AL" "OH" "FL" "TX" "CA"> <SQL "select Name from states where Abbr like $list"> $Name </SQL> |
Here the $list variable is passed as a query parameter to <SQL> . Since it is a string, and has multiple values, these values are concatenated and passed as the Metamorph set list string (AL,OH,FL,TX,CA) . Thus the search would find any of the states listed.
It is important to note that this multi-value concatenation only happens with varchar (string) parameters. Also, care must be taken with non-select statements, to avoid inadvertently changing the value for an insert or update .
Back: SQL Parameters | Next: Altering the Query with $null |