PreviousNextIndex

UPDATE statement

Displays fields or variables, requests input, and then puts the input data in both the screen buffer and in the specified fields or variables.

The UPDATE statement is a combination of the following statements:

Data movement

Syntax

UPDATE 
  [ UNLESS-HIDDEN ] 
  [   field [ format-phrase ] [ WHEN expression ]  
    | TEXT ( field [ format-phrase ] ... )  
    | field = expression   
    | constant [ AT n | TO n ]  
    | ^  
    | SPACE [ ( n ) ]  
    | SKIP [ ( n )]  
  ] ...  
  [ GO-ON ( key-label ... ) ] 
  [ frame-phrase ] 
  [ editing-phrase ] 
  [ NO-ERROR ] 

UPDATE record 
  [ EXCEPT field ... ] 
  [ frame-phrase ] 
  [ NO-ERROR ] 

UNLESS-HIDDEN
field
format-phrase
WHEN expression
TEXT
field = expression
constant AT n
constant TO n
^
SPACE [ ( n ) ]
SKIP [ ( n ) ]
GO-ON ( keylabel . . . )
frame-phrase
editing-phrase
NO-ERROR
record
EXCEPT field
Examples

The following procedure lets you update the Name, Address, City, State, and Country for each Customer record in the database:

r-updat.p
FOR EACH Customer: 
  UPDATE Customer.Name Customer.Address Customer.City Customer.State 
    Customer.Country. 
END. 

The r-updat2.p procedure reads each Customer record and lets you update the Name and CreditLimit fields. The VALIDATE option on the first UPDATE statement ensures that you enter a CreditLimit value that is less than 500000. The HELP option displays a message to that effect.

r-updat2.p
FOR EACH Customer: 
  UPDATE Customer.Name 
    Customer.CreditLimit VALIDATE(Customer.CreditLimit < 500000, "Too high") 
    HELP "Enter CreditLimit < 500000". 
  FOR EACH Order OF Customer: 
    DISPLAY Order.OrderNum. 
    UPDATE Order.PromiseDate Order.ShipDate VALIDATE(Order.ShipDate > TODAY, 
      "Ship date must be later than today"). 
  END. 
END. 

The second FOR EACH block reads every Order belonging to the Customer, displays the OrderNum field, and lets you update the PromiseDate and ShipDate fields. The VALIDATE option ensures that you enter a ship date value that is after today’s date.

This procedure requests a Customer number and then lets you update information for that Customer record. The frame phrase WITH 1 COLUMN 1 DOWN tells the AVM to display the fields in a single column on the screen (rather than in a row across the screen) and to display only one Customer record on the screen at a time.

r-updat3.p
REPEAT: 
  PROMPT-FOR Customer.CustNum. 
  FIND Customer USING Customer.CustNum. 
  UPDATE Customer.Name Customer.Address Customer.City Customer.State 
    Customer.Country WITH 1 COLUMN 1 DOWN. 
END. 

Notes
See also

ASSIGN statement, DISPLAY statement, EDITING phrase, Format phrase, Frame phrase, PROMPT-FOR statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex