In this section: |
How to: |
Reference: |
The MAINTAIN command marks the beginning of a Maintain Data procedure. You can identify any data sources the procedure will access using the FILE phrase. If the request is to be called from another procedure, you can identify variables to be passed from and to the calling procedure using the FROM and INTO phrases.
The syntax of the MAINTAIN command is
MAINTAIN [FILE[S] filelist] [FROM varlist] [INTO varlist] filelist:filedesc [{AND|,} filedesc ...] varlist: {variable} [{variable} ...]
where:
Identifies the beginning of a Maintain Data request. It must be coded in uppercase letters.
Indicates that the procedure accesses Master Files. The S can be added to FILE for clarity. The keywords FILE and FILES may be used interchangeably.
You access a Master File when you read or write to a data source, and when you use an INFER command to define the data source columns of a stack. For example, when you redefine a stack that has been passed from a parent procedure.
Is included if this procedure is called by another procedure, and that procedure passes one or more variables.
Is included if this procedure is called by another procedure, and this procedure passes one or more variables back to the calling procedure.
Are the names of the Master Files this procedure accesses.
Are the names of the Master Files that describe the data sources that are accessed in the procedure.
Is used to separate Master File names.
Is used to separate Master File names.
Are the variables, both scalar variables and stacks, which are passed to or from this procedure. Multiple variables are separated by blank spaces.
Are the names of the scalar variables or stacks. You can pass any variable, except for those defined as variable-length character (that is, those defined as TX or A0) and those defined using STACK OF.
The MAINTAIN command does not require any parameters. This means that Maintain Data procedures do not need to access data sources or stacks. You can use a procedure as a subroutine when sharing functions among different procedures, or when certain logic is not executed very frequently. For example, to begin a procedure that does not access any data sources and does not have any stacks as input or output, you simply begin the procedure with the keyword MAINTAIN.
However, the keyword FILE and the name of the Master File are required if you want to access a data source. The following example accesses the Employee data source:
MAINTAIN FILE Employee
A Maintain Data procedure can access several data sources by naming the corresponding Master Files in the MAINTAIN command:
MAINTAIN FILES Employee AND EducFile AND JobFile
You can use the CALL command to pass control to another procedure. When the CALL command is issued, control is passed to the named procedure. Once that procedure is complete, control returns to the item that follows the CALL command in the calling procedure.
Called procedures can also reside on remote Reporting Servers, allowing you to partition the logic of your application between machines.
For information about the CALL command, see CALL.
You can pass stacks and variables between procedures by using FROM and INTO variable lists. In the following example, when the CALL Validate command is reached, control is passed to the procedure named Validate along with the Emps stack. Once Validate is complete, the data in the ValidEmps stack is sent back to the calling procedure. Notice that the calling and called procedures both have the same FROM and INTO stack names. Although this is not required, it is good practice to avoid giving the same stacks different names in different procedures.
The calling procedure contains:
MAINTAIN FILE Employee FOR ALL NEXT Emp_ID INTO Emps; INFER emp_id into Validemps;
CALL Validate FROM Emps INTO ValidEmps; . . . END
The called procedure (Validate) contains:
MAINTAIN FILE Employee FROM Emps INTO ValidEmps . . . END