In calculations involving many large fields, you can control your results better by breaking the expression
into parts, calculating each part as a separate result field. Then you can use these result fields in an
expression to calculate the result field you want. You can specify length and decimal positions for the
intermediate result fields to minimize the length of the final result field.
For example:
X12 = (1.2998 − P − Q)/((R + S) * (T − U)) + 6
Instead of defining result field
X12
in one step as above, you could do it in three:
X12PART1 = 1.2998 − P − Q
X12PART2 = (R + S) * (T − U)
X12 = X12PART1/X1 6
If the user knows that
X12PART1
, for example, is always a number between 0 and 1.2998, the user can
specify
5
for
Len
and
4
for
Dec
(on the Define Result Fields display) for
X12PART1
. This decreases the
length of
X12
.
Length and decimal positions used for internal numeric calculations in
Query for iSeries
The following formulas define the maximum length and decimal positions used internally by Query for
decimal calculations for numeric result fields. The maximum length and decimal positions do not
necessarily correspond with the presentation length and decimal positions assigned by Query. The
symbols
p
and
d
denote the length and decimal positions of the first operand. The symbols
p
1
and
d
1
denote the length and decimal positions of the second operand.
Addition and subtraction in Query for iSeries
The maximum length for the result field:
min(31,max(p-d,p
1
-d
1
)+max(d,d
1
)+1)
.
The maximum decimal positions:
max(d,d
1
)
.
Multiplication in Query for iSeries
The maximum length for the result field:
min(31,p+p
1
)
The maximum decimal positions:
min(31,d+d
1
)
.
Division in Query for iSeries
The maximum length for the result field:
31
The maximum decimal positions:
31-p+d-d
1
.
Chapter 17. Additional information about Query for iSeries for programmers
189
Summary of Contents for ISERIES SC41-5210-04
Page 1: ...iSeries Query for iSeries Use Version 5 SC41 5210 04 ERserver ...
Page 2: ......
Page 3: ...iSeries Query for iSeries Use Version 5 SC41 5210 04 ERserver ...
Page 12: ...x Query for iSeries Use V5R2 ...
Page 14: ...2 Query for iSeries Use V5R2 ...
Page 32: ...20 Query for iSeries Use V5R2 ...
Page 38: ...26 Query for iSeries Use V5R2 ...
Page 44: ...32 Query for iSeries Use V5R2 ...
Page 116: ...104 Query for iSeries Use V5R2 ...
Page 122: ...110 Query for iSeries Use V5R2 ...
Page 146: ...134 Query for iSeries Use V5R2 ...
Page 150: ...138 Query for iSeries Use V5R2 ...
Page 174: ...162 Query for iSeries Use V5R2 ...
Page 178: ...166 Query for iSeries Use V5R2 ...
Page 196: ...184 Query for iSeries Use V5R2 ...
Page 198: ...186 Query for iSeries Use V5R2 ...
Page 204: ...192 Query for iSeries Use V5R2 ...
Page 205: ...Part 4 Appendixes Copyright IBM Corp 2000 2002 193 ...
Page 206: ...194 Query for iSeries Use V5R2 ...
Page 210: ...198 Query for iSeries Use V5R2 ...
Page 242: ...230 Query for iSeries Use V5R2 ...
Page 256: ...244 Query for iSeries Use V5R2 ...
Page 270: ...258 Query for iSeries Use V5R2 ...
Page 272: ...260 Query for iSeries Use V5R2 ...
Page 292: ...280 Query for iSeries Use V5R2 ...
Page 293: ......
Page 294: ... Printed in U S A SC41 5210 04 ...