Consultor Eletrônico



Kbase 18465: SetQueryWhere removes SDO Foreign Field Mapping
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Verified

FACT(s) (Environment):

Progress 9.x

SYMPTOM(s):

SetQueryWhere overwrites foreign field based where clause.

ADM2

CAUSE:

The problem is a known issue.

Take the example where your application has an SDO for Customers and an SDO for Orders that are linked with a data link, and foreign field mapping is used to map the CustNum field between the two objects.

If you are allowed to enter a starting date to be used as criteria in the Order query WHERE clause, the following code might be used:

DEFINE VARIABLE pcWhere AS CHARACTER NO-UNDO.

ASSIGN pcWhere = "OrderDate >= " dStartDate:SCREEN-VALUE.

DYNAMIC-FUNCTION('setQueryWhere':U IN h_dorder, INPUT pcWhere).
DYNAMIC-FUNCTION('openQuery':U IN h_dorder).

If you entered 01/01/1998 as the starting date, the above code changes the WHERE clause of the query from:

FOR EACH Order WHERE Order.CustNum = 1 NO-LOCK    /* uses Foreign Fields */

to:

FOR EACH Order WHERE OrderDate > "01/01/1998".

The foreign fields information has been lost and all all orders with an order date later than or equal to 01/01/1998 displays, not orders that are based on the current customer.

FIX:

The following code can be used as a workaround to maintain the foreign fields portion of the WHERE clause:

DEFINE VARIABLE pcWhere AS CHARACTER NO-UNDO.
DEFINE VARIABLE cforfld AS CHARACTER NO-UNDO.
DEFINE VARIABLE cforval AS CHARACTER NO-UNDO.

cforfld = ENTRY(1,DYNAMIC-FUNCTION('getForeignFields':U IN h_dorder)).
cforval = DYNAMIC-FUNCTION('getForeignValues':U IN h_dorder).

pcWhere = cforfld + " = " + cforval + " AND OrderDate >= " dStartDate:SCREEN-VALUE.

DYNAMIC-FUNCTION('setQueryWhere':U IN h_dorder, INPUT pcWhere).
DYNAMIC-FUNCTION('openQuery':U IN h_dorder).

This uses getForeignFields and getForeignValues to get the foreign field information needed in the WHERE clause. The clause is now:

FOR EACH Order WHERE Order.CustNum = 1 AND OrderDate >= 01/01/1998 NO-LOCK

All orders for the current customer (customer number 1 in this example) with an order date that is greater than or equal to the entered date (01/01/1998 in this example) display.