IBM SC41-5210-04 Server User Manual


 
When you do more than one calculation within a numeric expression, use parentheses to tell Query in
what order to do the calculations and to make the expression easier to understand. If you use nested
parentheses for example, 60*(A−(B+C)), the calculations are done for the innermost pair first (in the
example, B+C), then the next innermost pair, and so on. If you do not use parentheses, Query first does
multiplication and division, left to right, and then addition and subtraction, left to right. For example, (5 +
4)*2equals 18, but 5+4*2equals 13.
Be aware that the result of a numeric expression, especially one containing division and multiplication
operations, is truncated or rounded depending on what you specify on the Specify Processing Options
display (see Chapter 14, Specifying Query for iSeries processing options). If you divide by zero, your
query may not run.
Query for iSeries character expressions
To define a character result field (that is, a result field that contains SBCS or DBCS characters) for your
query, you need to follow the rules for creating character expressions. A character expression for a result
field can contain the following, alone or in combination:
v Character field names (names of fields that contain SBCS or DBCS characters). You can use the
names of SBCS- or DBCS-character fields listed on the lower part of the display (in the Dec column,
SBCS-character fields have blanks or Vs (if variable length), DBCS-only fields have Js, DBCS-open
fields have Os, DBCS-either fields have Es, and DBCS-graphic fields have Gs) and the names of
previously defined SBCS- or DBCS-character result fields.
v Character constants (SBCS or DBCS characters enclosed in apostrophes, such as ’ABCdef123’ or
’This text includes blanks and special characters **$$’). The rules for using character constants
are:
The character constant must be enclosed in apostrophes.
Any combination of letters, numbers, or special characters (for example, $ or #) can be used.
If two apostrophes are used within a character string, the two apostrophes become a single
apostrophe in the output. For example, ’October’s Profits’ becomes October’s Profits.
Words with lowercase and uppercase letters are used exactly as typed.
If a character constant represents a valid date, time, or timestamp, and is used with a date, time, or
timestamp field, it is considered a date, time, or timestamp constant.
A DBCS character constant must include DBCS shift-out and shift-in characters, represented by the
characters < and > in the following example: ’<D1D2D3>’. A DBCS-graphic character constant must
be preceded by an uppercase or lowercase G, for example, G’<D1D2D3>’.
v Character operators and functions (one or more concatenation operations and character functions
SUBSTR, DIGITS, and VALUEsee Query for iSeries character functionson page 61).
Query for iSeries concatenation operation
Character expressions can include one or more concatenation operations. Concatenation operations must
be specified in the form:
 value-1 || value-2 
v Value-1 and Value-2 are the character fields or character constants that are to be concatenated. You
can use SBCS- and DBCS-character field names (including character result fields) and character
constants (including DBCS-open, DBCS-only, and DBCS-graphic constants). A DBCS-graphic field can
be concatenated only with another DBCS-graphic field or constant.
v Two logical OR symbols (||) make up the concatenation operator used to join the two values. (See
CCSID and result field expressions in Query for iSerieson page 252 to see how CCSIDs are handled
for the concatenation symbol.)
60 Query for iSeries Use V5R2