MAINTAIN

In this section:

How to:

Reference:

The MAINTAIN command marks the beginning of a Maintain 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.


Top of page

x
Syntax: How to Use the MAINTAIN Command

The syntax of the MAINTAIN command is

MAINTAIN [FILE[S] filelist] [FROM varlist] [INTO varlist]
  filelist:filedesc [{AND|,} filedesc ...]
  varlist: {variable} [{variable} ...]

where:

MAINTAIN

Identifies the beginning of a Maintain request. It must be coded in uppercase letters.

FILE[S]

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.

FROM

Is included if this procedure is called by another procedure, and that procedure passes one or more variables.

INTO

Is included if this procedure is called by another procedure, and this procedure passes one or more variables back to the calling procedure.

filelist

Is the names of the Master Files this procedure accesses.

filedesc

Is the name of the Master File that describes the data source that is accessed in the procedure.

AND

Is used to separate Master File names.

,

Is used to separate Master File names.

varlist

Is the variables, both scalar variables and stacks, which are passed to or from this procedure. Multiple variables are separated by blank spaces.

variable

Is the name of a scalar variable or stack. 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.


Top of page

x
Reference: Usage Notes for MAINTAIN

Top of page

x
Reference: Commands Related to MAINTAIN

Top of page

x
Specifying Data Sources With the MAINTAIN Command

The MAINTAIN command does not require that any parameters are supplied. This means that Maintain 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 procedure can access several data sources by naming the corresponding Master Files in the MAINTAIN command:

MAINTAIN FILES Employee AND EducFile AND JobFile

Top of page

x
Calling a Procedure From Another Procedure

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 WebFOCUS Servers, allowing you to partition the logic of your application between machines.

For information about the CALL command, see CALL.



Example: Passing Variables Between Procedures

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 stack ValidEmps 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

WebFOCUS