Progress
Language Reference


GET Statement

Interfaces
OS
SpeedScript
All
All
Yes

Returns one record for a previously opened query.

SYNTAX

GET { FIRST | NEXT | PREV | LAST | CURRENT } query
    [ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ]
    [ NO-WAIT ] 

FIRST query

Finds the first record associated with the query. The query must have been previously opened in an OPEN QUERY statement. The order of the records is determined by the options specified in the Record phrase the OPEN QUERY statement.

NEXT query

Returns the first or next record associated with the query. The query must have been previously opened in an OPEN QUERY statement. The order of the records is determined by the options specified in the OPEN QUERY statement of the Record phrase.

PREV query

Returns the preceding or last record associated with the query. The query must have been previously opened in an OPEN QUERY statement. The order of the records is determined by the options specified in the OPEN QUERY statement of the Record phrase.

LAST query

Returns the last record associated with the query. The query must have been previously opened in an OPEN QUERY statement. The order of the records is determined by the options specified in the OPEN QUERY of the Record phrase.

CURRENT query

Refetches the current record or records associated with the query. The query must have been previously opened in an OPEN QUERY statement. If the query is a join, Progress returns the current record for all tables in the join.

SHARE-LOCK

Specifies that the record is share locked. Overrides the default locking of the OPEN QUERY statement. This applies to all buffers in a join.

EXCLUSIVE-LOCK

Specifies that the record is exclusively locked. Overrides the default locking of the OPEN QUERY statement. This applies to all buffers in a join.

NO-LOCK

Specifies that no lock is applied to the record. Overrides the default locking of the OPEN QUERY statement. This applies to all buffers in a join.

NO-WAIT

Specifies that the GET statement returns immediately if the record cannot be accessed because it is locked by another user. If you do not use the NO-WAIT option, the GET statement waits until the record can be accessed. This applies to all buffers in a join. If you specify NO-WAIT and the record is locked by another user, the record is returned to you with NO-LOCK and the LOCKED function returns TRUE for the record.

EXAMPLE

This procedure uses the GET statement to find customer orders.

r-getord.p
DEFINE QUERY cust-order FOR customer, order.

OPEN QUERY cust-order FOR EACH customer, 
  EACH order OF customer.

GET FIRST cust-order.

DO WHILE AVAILABLE(customer):

  DISPLAY customer.cust-num customer.name 
    WITH FRAME cust-info.
  DISPLAY order WITH FRAME order-info SIDE-LABELS.
  PAUSE.

  GET NEXT cust-order.
END. 

In the example, the GET FIRST statement fetches the first customer record and the first order record for that customer. The GET NEXT statement fetches the next order record for the customer. If no more order records are found for the current customer, then the GET NEXT statement fetches the next customer and the first order record for that customer. If a customer has no orders, the GET statement skips that customer.

NOTES

SEE ALSO

AVAILABLE Function, CLOSE QUERY Statement, CURRENT-CHANGED Function, CURRENT-RESULT-ROW Function, DEFINE QUERY Statement, FIND Statement, FOR Statement, LOCKED Function, NUM-RESULTS Function, OPEN QUERY Statement, REPOSITION Statement


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