Purpose
You can set the value of a temporary result to be the value that results from an arithmetic expression.
Syntax Diagram
The following is the syntax for the SET statement when you want to set the result to equal the value resulting from an arithmetic expression.
►►─ SET ─ result ─┬─────────┬─ =arithmetic-expression ────────────────────────►◄ └─ (n.d) ─┘
Explanation
The following explains the keywords in the preceding format.
Assigns a name to the new result. A result name can be up to 32 alphanumeric characters, with an alphabetic first character.
Specifies the precision (the specific number of digits before and after the decimal) of the result, overriding the default precision. (n.d) indicates that the result contains n integers and d decimals. The total of n + d cannot exceed 18 digits.
For example, (9.2) specifies a result with nine integer positions and two decimal positions. The total number of digits is 11.
Specifies one or more arithmetic operations to be performed on selected data, including null-valued columns. If a computation is done involving null values, the result is null. CA Dataquery evaluates the expression according to the hierarchy of operations. (For more information, see Evaluation of Arithmetic Expressions.)
Sample
This is a sample query which illustrates SET statements using arithmetic expressions.
FIND CAI-SLSHST-REC ROWS
WITH SHIP-QTY GTE 200
RELATED BY SLMN-ID TO CAI-ORDERS-REC
SET NET-COST (8.2) = CAI-SLSHST-REC SHIP-QTY * UNIT-PRICE
SET DISCOUNT (5.2) = NET-COST * DISC-PCT
SET DISCOUNT-COST (8.2) = NET-COST - DISCOUNT
PRINT FROM CAI-ORDERS-REC ORD-ID
FROM CAI-SLSHST-REC ITM-ID
SHIP-QTY
UNIT-PRICE
NET-COST
DISCOUNT
DISCOUNT-COST
Sample
The CAI-SLSHST-REC table looks like this:
|
SHIP |
ORD |
CUST |
SLMN |
DISC |
IND |
UNIT |
ITM |
|---|---|---|---|---|---|---|---|
|
103 |
880117 |
QW10000 |
SMITH |
0.10 |
XZ-234 |
1.25 |
CAPS |
|
400 |
880319 |
RM10000 |
JONES |
0.10 |
AM-789 |
7.00 |
MATS |
|
200 |
880215 |
UV9999 |
WATT |
0.10 |
XZ-744 |
3.00 |
LOCKS |
|
167 |
890117 |
RV8009 |
ROBB |
0.05 |
AA-909 |
2.37 |
DIAL |
|
300 |
890215 |
XY3375 |
ADAMS |
0.10 |
ZM-889 |
5.00 |
VISOR |
Sample
The CAI-ORDERS-REC table looks like this:
|
ORD |
ORD |
CUST |
SLMN |
SHIP |
ITM |
FRT |
GROUP |
|---|---|---|---|---|---|---|---|
|
BR950 |
2595.00 |
RT900 |
JONES |
LMN-12-1 |
MATS |
75.00 |
AMA |
|
CQ322 |
573.99 |
RT907 |
WATT |
LMN-33-7 |
LOCK |
33.99 |
AMA |
|
RR995 |
17.50 |
RT899 |
SMITH |
ALV-01-1 |
CAPS |
1.25 |
AMA |
|
AW009 |
1433.00 |
RT999 |
ADAMS |
ARR-33-9 |
VISOR |
83.00 |
CRA |
Sample
The active found set for the preceding query looks like this:
|
ORD |
ITM |
SHIP |
UNIT |
NET |
DISCOUNT |
DISCOUNT |
|---|---|---|---|---|---|---|
|
BR950 |
MATS |
400 |
7.00 |
2800.00 |
280.00 |
2520.00 |
|
CQ322 |
LOCK |
200 |
3.00 |
600.00 |
60.00 |
540.00 |
|
AW009 |
VISOR |
300 |
5.00 |
1500.00 |
150.00 |
1350.00 |
|
Copyright © 2014 CA.
All rights reserved.
|
|