Many MetaSQL statements are written to behave in special ways if specific parameters are active or not. For example, many screens let you choose to see Items with all Class Codes, just some Class Codes, or a particular Class Code. These work by having queries that check whether certain MetaSQL parameters are active or not:
SELECT ... FROM item, ... WHERE ... <? if exists("classcode_id") ?> AND (item_classcode_id=<? value("classcode_id") ?>) <? elseif exists("classcode_pattern") ?> AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ <? value("classcode_pattern") ?>))) <? endif ?> ...
In this example, when the user selects a particular Class
Code, the screen makes the classcode_id
parameter
active. The query then looks only at items with the selected Class
Code. If the user enters a Pattern, then the screen makes the
classcode_pattern
parameter active and all Items
with Class Codes matching that pattern are displayed. If neither
classcode_id
nor
classcode_pattern
is active, there is no
comparison with any Class Code and so all Class Codes are
displayed.
If you are not going to make a MetaSQL Parameter active, you do not need to set the type or value for it before submitting the MetaSQL Statement to the xTuple Connect Batch Manager.