Natural for OpenVMS Version 6.3.12 for OpenVMS
 —  Statements  —

AT END OF DATA

Structured Mode Syntax

[AT] END [OFDATA  [(r)]
   statement ../graphics/dot3.gif
END-ENDDATA

Reporting Mode Syntax

[AT] END [OFDATA  [(r)]

statement

DO statement ../graphics/dot3.gif DOEND

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

Related Statements: ACCEPT/REJECT | AT BREAK | AT START OF DATA | BACKOUT TRANSACTION | BEFORE BREAK PROCESSING | DELETE | END TRANSACTION | FIND | GET | GET SAME | GET TRANSACTION DATA | HISTOGRAM | LIMIT | PASSW | PERFORM BREAK PROCESSING | READ | RETRY | STORE | UPDATE

Belongs to Function Group: Database Access and Update


Function

The AT END OF DATA statement is used to specify processing to be performed when all records selected for a database processing loop have been processed.

This section covers the following topics:

See also AT START/END OF DATA Statements in the Programming Guide.

Processing

This statement is non-procedural, that is, its execution depends on an event, not on where in a program it is located.

Values of Database Fields

When the AT END OF DATA condition for the processing loop occurs, all database fields contain the data from the last record processed.

Positioning

This statement must be specified within the same program module which contains the loop creating statement.

System Functions

Natural system functions may be used in conjunction with an AT END OF DATA statement as described in Using System Functions in Processing Loops in the System Functions documentation.

Top of page

Restrictions

Top of page

Syntax Description

Syntax Element Description
(r)
Reference to a Specific Processing Loop:
An AT END OF DATA statement may be related to a specific active processing loop by using the notation (r).

If this notation is not used, the AT END OF DATA statement will be related to the outermost active database processing loop.

statement ...
Statement(s) to be Executed at End of Data Condition:

In structured mode, you must supply one or several suitable statements, depending on the situation. For an example of a statement, see Example below.

END-ENDDATA
End of AT END OF DATA Statement:

In structured mode, the Natural reserved word END-ENDDATA must be used to end the AT END OF DATA statement.

In reporting mode, use the DO ... DOEND statements to supply one or several suitable statements, depending on the situation, and to end the AT END OF DATA statement. If you specify only a single statement, you can omit the DO ... DOEND statements. With respect to good coding practice, this is not recommended.

statement ...
DO statement ... DOEND

Top of page

Example

** Example 'AEDEX1S': AT END OF DATA                                    
************************************************************************
DEFINE DATA LOCAL                                                       
1 EMPLOY-VIEW VIEW OF EMPLOYEES                                         
  2 PERSONNEL-ID                                                        
  2 NAME                                                                
  2 FIRST-NAME                                                          
  2 SALARY    (1)                                                       
  2 CURR-CODE (1)                                                       
END-DEFINE                                                              
*                                                                       
LIMIT 5                                                                 
EMP. FIND EMPLOY-VIEW WITH CITY = 'STUTTGART'                           
  IF NO RECORDS FOUND                                                   
    ENTER                                                               
  END-NOREC                                                             
  DISPLAY PERSONNEL-ID NAME FIRST-NAME                                  
          SALARY (1) CURR-CODE (1)                                      
  /*
   AT END OF DATA                                               
    IF *COUNTER (EMP.) = 0                                     
      WRITE 'NO RECORDS FOUND'                                 
      ESCAPE BOTTOM                                            
    END-IF                                                     
    WRITE NOTITLE / 'SALARY STATISTICS:'                       
                  / 7X 'MAXIMUM:' MAX(SALARY(1))  CURR-CODE (1)
                  / 7X 'MINIMUM:' MIN(SALARY(1))  CURR-CODE (1)
                  / 7X 'AVERAGE:' AVER(SALARY(1)) CURR-CODE (1)
    END-ENDDATA 
  /*                                                           
END-FIND                                                       
*                                                              
END                                                           

See also Natural System Functions for Use in Processing Loops in the System Functions documentation.

Output of Program AEDEX1S:

PERSONNEL         NAME              FIRST-NAME        ANNUAL   CURRENCY
   ID                                                 SALARY     CODE  
--------- -------------------- -------------------- ---------- --------
                                                                       
11100328  BERGHAUS             ROSE                      70800 DM      
11100329  BARTHEL              PETER                     42000 DM      
11300313  AECKERLE             SUSANNE                   55200 DM      
11300316  KANTE                GABRIELE                  61200 DM      
11500304  KLUGE                ELKE                      49200 DM      
                                                                       
SALARY STATISTICS:                                                     
       MAXIMUM:      70800 DM                                          
       MINIMUM:      42000 DM                                          
       AVERAGE:      55680 DM                                         

Equivalent reporting-mode example: AEDEX1R.

Top of page