DATA statement

Syntax

DATA expression [ ,expression ...]

Description

Use the DATA statement to place values in an input stack. These values can be used as responses to INPUT statements executed later in the program or in a subroutine (see the INPUT statement). The values can also serve as responses to InfoSphere® DataStage® commands that request input.

Expressions used in DATA statements can be numeric or character string data. The null value cannot be stored in the input stack. If expression evaluates to null, the DATA statement fails and the program terminates with a run-time error message.

Put a comma at the end of each line of a DATA statement to indicate that more data expressions follow on the next line.

The order in which expressions are specified in the DATA statement is the order in which the values are accessed by subsequent INPUT statements: first-in, first-out. When all DATA values have been exhausted, the INPUT statement prompts the user for a response at the terminal.

The DATA statement must be executed before an INPUT statement that is to use expression for input.

You can store up to 512 characters in a data stack.

You can list the current data in the stack from your program by accessing the @DATA.PENDING variable with the statement:

PRINT @DATA.PENDING

Example

In the following example, the INPUT NBR statement uses the first value placed in the input stack by the DATA statement, 33, as the value of NBR. The INPUT DESCR statement uses the second value, 50, as the value of DESCR. The INPUT PRICE statement uses the third value, 21, as the value of PRICE.

X=33;  Y=50; Z=21
DATA X,Y,Z
X=Y+Z
*
INPUT NBR
INPUT DESCR
INPUT PRICE
INPUT QTY
PRINT NBR,DESCR,PRICE,QTY

This is the program output:

?33
?50
?21
?2
33       50        21        2

The value of NBR is the value of X when the DATA statement is executed, not the current value of X (namely, Y+Z). The INPUT QTY statement has no corresponding value in the input stack, so it prompts the user for input.