Language Summary

In this section:

This topic summarizes all Maintain Data language commands, grouping them by their primary use, such as transferring control or selecting records. Each command and system variable is described in detail later in this chapter.

Defining a Procedure

The basic syntax consists of the commands that start and terminate a Maintain Data procedure. The commands are:

MAINTAIN

Initiates the parsing and execution of a Maintain Data procedure. It is always the first line of the procedure.

END

Terminates the execution of a Maintain Data procedure.

Defining a Maintain Data Function (a Case)

The following command defines Maintain Data functions:

CASE

Defines a Maintain Data function. Maintain Data functions are also known as cases.

Defining Blocks of Code

The following command defines a block a code:

BEGIN

Defines a group of commands as a single block and enables you to issue them as a group. You can place a BEGIN block anywhere individual commands can appear.

Transferring Control

You can transfer control to another function within the current procedure, as well as to another procedure.

The commands that transfer control are:

PERFORM

Transfers control to another function. When the function finishes, control is returned to the command following PERFORM. You can also call a function directly, without PERFORM.

GOTO

Transfers control to another function or to a special label within the current function. When the function finishes, control does not return. You can also call a function directly, without GOTO.

CALL

Executes another Maintain Data procedure.

EXEC

Executes an external (non-Maintain Data) procedure.

Executing Procedures

The following commands run procedures, or prepare them for execution:

CALL

Executes a Maintain Data procedure, and enables you to pass data from the calling procedure.

EXEC

Executes an App Studio procedure.

Using Loops

The following command supports looping:

REPEAT

Enables a circular flow of control.

Using Forms

The following command is responsible for presentation logic:

Winform

Displays a form by which end users can read, enter, and edit data.

Defining Classes

The following command enables you to define classes:

DESCRIBE

Defines classes and data type synonyms.

Creating Variables

The following commands enable you to create variables:

DECLARE

Creates local and global variables, including objects.

COMPUTE

Creates global variables, including global objects. It can also assign values to existing variables.

Assigning Values

Maintain Data enables you to assign values to existing variables using the following command:

COMPUTE

Assigns values to existing variables.

Manipulating Stacks

Maintain Data provides several stack commands to manage the contents of stacks. Unless otherwise specified, each command operates on all rows in the stack. The following example copies the contents of the Indata stack to the Outdata stack:

FOR ALL COPY FROM Indata INTO Outdata;

One row or a range of rows may be specified to limit which rows are affected. For example, the following copies 100 records of the Indata stack, starting from the fourth record, and places them into the Outdata stack.

FOR 100 COPY FROM Indata(4) INTO Outdata;

The stack commands are:

COPY

Copies data from one stack to another.

STACK SORT

Sorts data in a stack.

STACK CLEAR

Initializes a stack.

INFER

Defines the columns in a stack.

In addition, there are two variables associated with a stack which can be used to manipulate individual rows or groups of rows in the stack. The stack variables are:

FocCount

Is the number of rows in the stack.

FocIndex

Is a pointer to the current instance in the stack.

Selecting and Reading Records

The record selection commands retrieve data from the data source and change position in the data source.

The commands are:

NEXT

Starts at the current position and moves forward through the data source. NEXT can retrieve data from one or more rows.

MATCH

Searches the entire segment for a matching field value. It retrieves an exact match in the data source.

REPOSITION

Changes the data source position to be at the beginning of the chain.

In addition, there is a system variable that provides a return code for NEXT and MATCH:

FocFetch

Signals the success or failure of a NEXT or MATCH command.

You can use the following commands to directly interface with a DBMS:

SYS_MGR.PRE_MATCH

Turns off preliminary database operation checking before an update.

SYS_MGR.GET_PRE_MATCH

Determines whether prematch checking is on or off.

SYS_MGR.ENGINE

Passes SQL commands directly to a DBMS.

SYS_MGR.DBMS_ERRORCODE

Retrieves a DBMS return code after an operation.

Conditional Actions

The conditional commands are:

IF

Issues a command depending on how an expression is evaluated.

ON MATCH

Determines the action to take when the prior MATCH command succeeds.

ON NOMATCH

Defines the action to take if the prior MATCH fails.

ON NEXT

Defines the action to take if the prior NEXT command succeeds.

ON NONEXT

Defines the action to take if the prior NEXT command fails.

Writing Transactions

The commands that can be used to control transactions are:

INCLUDE

Adds one or more new data source records.

UPDATE

Updates the specified data source fields or columns. Can update one or more records at a time.

REVISE

Adds new records to the data source and updates existing records.

DELETE

Deletes one or more records from the data source.

COMMIT

Makes all data source changes since the last COMMIT permanent.

ROLLBACK

Cancels all data source changes made since the last COMMIT.

There are several system variables that you can use to determine the success or failure of a data source operation or an entire logical transaction:

FocCurrent

Signals the success or failure of a COMMIT or ROLLBACK command.

FocError

Signals the success or failure of an INCLUDE, UPDATE, REVISE, or DELETE command.

FocErrorRow

If an INCLUDE, UPDATE, REVISE, or DELETE command that writes from a stack fails, this returns the number of the row that caused the error.

You can use the following commands to directly interface with a DBMS:

SYS_MGR.PRE_MATCH

Turns off preliminary database operation checking before an update.

SYS_MGR.GET_PRE_MATCH

Determines whether prematch checking is on or off.

SYS_MGR.ENGINE

Passes SQL commands directly to a DBMS.

SYS_MGR.DBMS_ERRORCODE

Retrieves a DBMS return code after an operation.

Setting Reporting Server Parameters

You can communicate with the Reporting Server using the following commands:

SET

Sets Reporting Server parameters. This command is outside the Maintain Data language, but is described in this chapter for your convenience.

SYS_MGR.FOCSET

Sets Reporting Server parameters, without having to set them in EDASPROF.

Using Libraries of Classes and Functions

You can import libraries using the following command:

MODULE

Imports a library of shared class definitions or functions into a Maintain Data procedure.

Messages and Logs

You can write messages to files, consoles, and forms using the following commands:

SAY

Writes messages to a file or to the default output device.

TYPE

Writes messages to a file or a form.

In addition, there is a system stack that is automatically populated with messages posted to the default output device by Maintain Data procedures, except for the starting procedure and external procedures:

FocMsg

Contains messages posted by Maintain Data and App Studio procedures.