Assignment Operators
Assignment operators are used in InfoSphere® DataStage® BASIC assignment statements to assign values to variables. Table 1 shows the operators and their uses.
| Operator | Syntax | Description |
|---|---|---|
| = | variable = expression | Assigns the value of expression to variable without any other operation specified. |
| += | variable += expression | Adds the value of expression to the previous value of variable and assigns the sum to variable. |
| -= | variable -= expression | Subtracts the value of expression from the previous value of variable and assigns the difference to variable. |
| := | variable := expression | Concatenates the previous value of variable and the value of expression to form a new value for variable. |
Table 2 shows some examples of assignment statements.
| Example | Interpretation |
|---|---|
| X = 5 | This statement assigns the value 5 to the variable X. |
| X += 5 | This statement is equivalent to X=X+5. It adds 5 to the value of the variable X, changing the value of X to 10 if it was originally 5. |
| X -= 3 | This statement is equivalent to X=X-3. It subtracts 3 from the value of the variable X, changing the value of X to 2 if it was originally 5. |
| X := Y | This statement is equivalent to X=X:Y. If the value of X is 'CON', and the value of Y is 'CATENATE', then the new value of the variable X is 'CONCATENATE'. |