PreviousNextIndex

NEW function (record buffers)

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
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-newrecord.p
REPEAT: 
  PROMPT-FOR Customer.CustNum. 
  FIND Customer USING Customer.CustNum NO-ERROR. 
  IF NOT AVAILABLE Customer THEN  
  DO WITH FRAME newcus: 
    MESSAGE "Creating new customer". 
    CREATE Customer. 
    ASSIGN Customer.CustNum. 
    UPDATE Customer.Name Customer.Address Customer.City Customer.State 
      Customer.Country. 
  END. 
  CREATE Order. 
  Order.CustNum = Customer.CustNum. 
  IF NEW Customer THEN DO: 
    UPDATE Order.OrderNum Order.PromiseDate. 
    Order.Terms = "COD". 
    DISPLAY Order.Terms. 
  END. 
  ELSE  
    UPDATE Order.OrderNum Order.PromiseDate 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


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex