Previous Next

WHERE-STRING attribute
Returns and allows you to modify the current WHERE expression from the query generated for a specified data-relation that links the child table to its parent.
Data type:
Access:
Applies to:
This attribute evaluates to the WHERE expression from the query that the AVM generates for you based on the data-relation between parent and child buffers. You can also use this attribute to build an extended query of your own based on this default relationship.
Note:
If you assign a new value to the attribute, the AVM uses the new WHERE expression when it re-opens the query during navigation to filter the child table of the data-relation. When you set this attribute, if the AVM finds an error in the new WHERE expression, it raises a run-time error on the assignment.
The NAME attribute of the Temp-table object handle is writeable for dynamic and AVM-generated temp-tables. You might need to update a WHERE-STRING that references a renamed temp-table with new strings using the new table name.
Typically, you modify an existing WHERE expression by appending additional conditions to it, as shown in the r-wherestr.p example procedure. This example provides the initial WHERE expression using the FILL-WHERE-STRING attribute. It then generates the complete initial query for the data-relation with the call to the ProDataSet FILL( ) method, and uses the WHERE-STRING attribute to modify the existing WHERE expression to further filter the query buffers.
 
DEFINE TEMP-TABLE ttCus LIKE Customer.
DEFINE TEMP-TABLE ttOrder LIKE Order.
DEFINE DATASET dsCus FOR ttCus,ttOrder DATA-RELATION dr1
  FOR ttCus, ttOrder RELATION-FIELDS(CustNum,CustNum).
 
DEFINE DATA-SOURCE dscCus FOR Customer.
DEFINE DATA-SOURCE dscOrd FOR Order.
 
DEFINE QUERY q1 FOR ttCus.
DEFINE QUERY q2 FOR ttOrder.
 
DEFINE BROWSE b1 QUERY q1 
  DISPLAY ttCus.CustNum ttCus.Name ttCus.Address WITH 3 DOWN.
DEFINE BROWSE b2 QUERY q2 
  DISPLAY ttOrder.CustNum ttOrder.OrderNum ttOrder.ShipDate WITH 6 DOWN.
 
BUFFER ttCus:ATTACH-DATA-SOURCE(DATA-SOURCE dscCus:HANDLE).
BUFFER ttOrder:ATTACH-DATA-SOURCE(DATA-SOURCE dscOrd:HANDLE).
DATA-SOURCE dscCus:FILL-WHERE-STRING = "WHERE CustNum < 3".
DATASET dsCus:FILL( ).
 
DATASET dsCus:GET-RELATION(1):WHERE-STRING 
  = DATASET dsCus:GET-RELATION(1):WHERE-STRING 
    + " AND ttOrder.OrderNum < 100". 
 
/* Shows full dataset */
FOR EACH ttCus:
  DISPLAY ttCus.CustNum.
  FOR EACH ttOrder OF ttCus:
    DISPLAY ttOrder.OrderNum ttOrder.OrderDate.
  END.
END.
 
BROWSE b1:QUERY = DATASET dsCus:TOP-NAV-QUERY.
BROWSE b2:QUERY = DATASET dsCus:GET-RELATION(1):QUERY.
 
/* Shows only filtered records */
ENABLE b1 b2 WITH FRAME frX ROW 1 SIZE 70 BY 30.
 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.
See also:

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.