Extraction Syntax Examples

Example 1: Selecting all records from a single Source File

EXTRACT PEOPLE(*)
{
    ARCHIVE MOVE PEOPLE [*];
}

In the above example all PEOPLE records are archived.

Example 2: Selecting records from a single Source File

EXTRACT PEOPLE(PEOPLE.CITY == "DERBY")
{
    ARCHIVE MOVE PEOPLE [*];
}

In the above example all PEOPLE records where the CITY field equals DERBY are archived.

Example 3: Selecting records from a single Source File based on current date

EXTRACT PEOPLE( PEOPLE.AH == [TODAY(-50Y,DATX)..TODAY(-40Y,DATX)] )
{
    ARCHIVE MOVE PEOPLE [*];
}

In the above example all PEOPLE records which are in the age range 40 – 50 years old are archived. Note the use of the DATX format in the TODAY() function to indicate field AH in the PEOPLE file contains the date of birth in Natural D-format.

EXTRACT PEOPLE( PEOPLE.AH < TODAY(-50Y,”YYYY-MM-DD”) )
{
    ARCHIVE MOVE PEOPLE [*];
}

In the above example all PEOPLE records which are over 50 years old are archived. Note the use of a user defined format to indicate field AH in the PEOPLE file contains the date of birth in a 10 byte Alpha field of format YYYY-MM-DD.

Example 4: Selecting records from multiple related Source Files

EXTRACT PEOPLE(PEOPLE.CITY == ["DERBY", "PARIS", "DETROIT"])
{
    ARCHIVE MOVE PEOPLE[*];
    
    EXTRACT CARS(CARS.PERSONNEL_ID == PEOPLE.PERSONNEL_ID)
    {
        ARCHIVE MOVE CARS[*];
    }

    EXTRACT OTHER(OTHER.PERSONNEL_ID== PEOPLE.PERSONNEL_ID)
    {
        ARCHIVE MOVE OTHER[*];
    }
}

In the above example all PEOPLE records where the CITY field equals DERBY, PARIS or DETROIT are archived. In addition, related records (based on PERSONNEL_ID) from the CARS file and OTHER file are also archived.