– If your expression performs a division operation, avoid dividing by zero by defining the denominator
as the result field just before the result field with a division. Then, for all logical OR groupings of
record selection, add a logical AND test stating the denominator must not equal zero.
v On the three lines provided, you can split a field name, numeric constant, or character string at the end
of one line and continue it at the beginning of the next. When you split a field name or a numeric
constant, do not put spaces at the end of the first line or at the beginning of the next line because
Query then treats it as two field names or numeric constants. Character constants (that is, characters
enclosed in apostrophes) can be split at any point. A DBCS character constant can be split by placing a
shift-in character in the last position of the upper line and a shift-out character in the first position of the
lower line.
v When using a field to divide, you must also select that field not equal to zero as the first selection
before any other result fields are processed, as in the following example:
v
1. AND/OR Field Test Value
2. ODQYSD NE 0
3. AND OMCRMM EQ 0
4. AND OMSTAT EQ ’50’
5. AND ODSTAT NE ’99’
6. AND PCT LT 90
7. AND PCT LT 90
8. AND OMUSOR LIST ’DT’’ET’’SR’’RT’
v To make your expressions easier to read, you can use blanks between field names and operators.
v You can create up to 100 result fields.
v Substring and concatenation operations are not allowed with date, time, timestamp or numeric fields. To
circumvent this, use the CHAR function around the date, time, or timestamp field and the DIGITS
function for numeric fields.
Query determines the data type of the result field according to the following:
If the first value in the expression is a numeric field name, a numeric constant (like the number 7 or
−3.14), or a function that returns a numeric value, then the result field is numeric.
If the SUBSTR function is used, the result field is an SBCS character field if the value is SBCS,
DBCS-only, or DBCS-either. The result field is a DBCS-open field if the value is DBCS-open. The result
field is a DBCS-graphic field if the value is DBCS-graphic. A substring of a fixed-length field can be
either a variable- or fixed-length field, depending on how you define the length and offset.
If the expression is a constant, field, or function, the data type of the result field is the data type of the
constant, field, or value returned by the function.
If the concatenation operation is used and all of the values being concatenated are DBCS-only, the
result field is DBCS-only.
If the concatenation operation is used and all of the values being concatenated are DBCS-graphic, the
result field is DBCS-graphic.
If the concatenation operation is used and one of the values being concatenated is DBCS-either, or if
the expression contains a mixture of SBCS and bracketed-DBCS fields or constants, the result field is
DBCS-open.
If a variable-length field is concatenated to either a fixed or variable-length field, the result is a
variable-length field.
If two or more fixed-length fields are concatenated, the result is a fixed-length field.
If two fixed-length DBCS fields are concatenated, the result is a variable-length field.
84 Query for iSeries Use V5R2