Progress
Language Reference


NEW Function

Interfaces
OS
SpeedScript
All
All
Yes

Checks a record buffer and returns a TRUE value if the record in that buffer is newly created. If the record was read from the database, NEW returns a FALSE value.

SYNTAX

NEW record 

record

The name of the record buffer you want to check with the NEW function.

To use the NEW function with a record in a table defined for multiple databases, you must qualify the record’s table name with the database name. See the Record Phrase reference entry for more information.

EXAMPLE

This procedure enters new orders, optionally creating a customer record if one does not exist. The NEW function is later used to select alternate processing depending if a customer is newly created or already exists.

r-new.p
REPEAT:
    PROMPT-FOR customer.cust-num.
    FIND customer USING cust-num NO-ERROR.
    IF NOT AVAILABLE customer
    THEN DO WITH FRAME newcus:
        MESSAGE "Creating new customer".
        CREATE customer.
        ASSIGN cust-num.
        UPDATE name address city st country.
    END.
    CREATE order.
    order.cust-num = customer.cust-num.
    IF NEW customer THEN DO:
        UPDATE order.order-num promise-date.
        order.terms = "COD".
        DISPLAY order.terms.
    END.
    ELSE UPDATE order.order-num promise-date order.terms.
END. 

NOTE

The NEW function returns a TRUE value only during the transaction in which the record is created. If the scope of the record is greater than the transaction in which the record is created, the NEW function returns a FALSE value outside the transaction.

SEE ALSO

AVAILABLE Function, FIND Statement, LOCKED Function, Record Phrase


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095