CHAIN statement

Syntax

CHAIN command

Description

Use the CHAIN statement to terminate execution of a BASIC program and to execute the value of command. command is an expression that evaluates to any valid InfoSphere® DataStage® command. If command evaluates to the null value, the CHAIN statement fails and the program terminates with a run-time error message.

Local variables belonging to the current program are lost when you chain from one program to another. Named and unnamed common variables are retained.

CHAIN differs from the EXECUTE statement or PERFORM statements in that CHAIN does not return control to the calling program. If a program chains to a procedure, any calling procedures that are nested are removed.

PICK, IN2, and REALITY Flavors

Unnamed common variables are lost when a chained program is invoked in a PICK, IN2, or REALITY flavor account. If you want to save the values of variables in unnamed common, use the KEEP.COMMON keyword to the RUN command at execution.

Example

The following program clears the screen, initializes the common area, and then runs the main application:

PRINT @(-1)
PRINT "INITIALIZING COMMON, PLEASE WAIT"
GOSUB INIT.COMMON
CHAIN "RUN BP APP.MAIN KEEP.COMMON"