Kbase P91489: How to change the Base Query of a SmartDataObject
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/26/2005 |
|
Status: Unverified
GOAL:
How to change the Base Query of a SmartDataObject
GOAL:
How to change the Base Query of an ADM2 SDO to something different at run time.
FIX:
For example to change an SDO with a query defined as:
FOR EACH Customer NO-LOCK,
FIRST Order OF Customer NO-LOCK
To:
FOR EACH Customer NO-LOCK,
FIRST Order OF Customer OUTER-JOIN NO-LOCK
Or:
FOR EACH Customer NO-LOCK,
FIRST Order OF Customer WHERE order.ordernum < 10 NO-LOCK
Use 'setbaseQuery' in initializeObject. However, if you set it after the SDO has been initialized (i.e. after RUN SUPER) then because the queryWhere property is not changed the SDO still uses this property. In this case you need to set queryWhere to blank after setting the base query. This way queryWhere adopts the new basequery value. e.g.:
RUN SUPER.
MESSAGE
"QueryString : " DYNAMIC-FUNCTION('getquerystring':U IN TARGET-PROCEDURE) SKIP
"QueryWhere : " DYNAMIC-FUNCTION('getquerywhere':U IN TARGET-PROCEDURE) SKIP
"BaseQuery : " DYNAMIC-FUNCTION('getbasequery':U IN TARGET-PROCEDURE).
/* DYNAMIC-FUNCTION('setBaseQuery':U IN TARGET-PROCEDURE, */
/* "FOR EACH customer NO-LOCK, */
/* FIRST Order OF Customer OUTER-JOIN NO-LOCK"). */
DYNAMIC-FUNCTION('setBaseQuery':U IN TARGET-PROCEDURE,
"FOR EACH customer NO-LOCK,
FIRST Order OF Customer WHERE order.ordernum < 10 NO-LOCK").
DYNAMIC-FUNCTION('setQueryWhere':U IN TARGET-PROCEDURE, "").
DYNAMIC-FUNCTION('openQuery':U IN TARGET-PROCEDURE).
MESSAGE
"QueryString : " DYNAMIC-FUNCTION('getquerystring':U IN TARGET-PROCEDURE) SKIP
"QueryWhere : " DYNAMIC-FUNCTION('getquerywhere':U IN TARGET-PROCEDURE) SKIP
"BaseQuery : " DYNAMIC-FUNCTION('getbasequery':U IN TARGET-PROCEDURE).