PreviousNextIndex

OPEN QUERY statement

Opens a query, which might have been previously defined in a DEFINE QUERY statement. Opening a query makes it available for use within a GET statement, or in a browse widget.

Syntax

OPEN QUERY query { FOR | PRESELECT } EACH record-phrase 
  [ , { EACH | FIRST | LAST } record-phrase ] ... 
  [ query-tuning-phrase ] 
  [ BREAK ] 
  [ BY expression [ DESCENDING ] 
    | COLLATE ( string , strength [ , collation ] ) [ DESCENDING ] 
  ] ... 
  [ INDEXED-REPOSITION ] 
  [ MAX-ROWS num-results ] 

query
{ FOR | PRESELECT } EACH record-phrase
{ EACH | FIRST | LAST } record-phrase
query-tuning-phrase
BREAK
BY expression [ DESCENDING ]
COLLATE ( string , strength [ , collation ] ) [ DESCENDING ]
string
strength
collation
INDEXED-REPOSITION
MAX-ROWS num-results
Example

The following example opens a query on the Customer, Order, OrderLine, and Item tables:

r-opqury.p
DEFINE QUERY q-order FOR Customer FIELDS(CustNum Name Phone), 
  Order FIELDS(OrderNum OrderDate), 
  OrderLine FIELDS(LineNum Price Qty), 
  Item FIELDS(ItemNum ItemName CatDesc). 
OPEN QUERY q-order FOR EACH Customer, 
  EACH Order OF Customer, 
  EACH OrderLine OF Order, 
  EACH Item OF OrderLine NO-LOCK. 
GET FIRST q-order. 
DO WHILE AVAILABLE Customer: 
  DISPLAY Customer.CustNum Customer.Name SKIP 
    Customer.Phone SKIP 
    Order.OrderNum Order.OrderDate SKIP 
    OrderLine.LineNum OrderLine.Price OrderLine.Qty SKIP 
    Item.OtemNum Item.ItemName SKIP 
    Item.CatDesc VIEW-AS EDITOR SIZE 50 BY 2 SCROLLBAR-VERTICAL 
    WITH FRAME ord-info CENTERED SIDE-LABELS TITLE "Order Information". 
  /* Allow scrolling, but not modification, of CatDesc. */ 
  ASSIGN item.cat-desc:READ-ONLY IN FRAME ord-info = TRUE 
         item.cat-desc:SENSITIVE IN FRAME ord-info = TRUE. 
  PAUSE. 
  GET NEXT q-order. 
END. /* DO WHILE AVAILABLE Customer */  

Note the use of field lists in the DEFINE QUERY statement. This can improve the performance of remote database queries significantly.

Notes
See also

CLOSE QUERY statement, CREATE QUERY statement, CURRENT-RESULT-ROW function, DEFINE BROWSE statement, DEFINE DATASET statement, DEFINE QUERY statement, GET statement, NUM-RESULTS function, QUERY-OFF-END function, QUERY-PREPARE( ) method, REPOSITION statement


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex