Consultor Eletrônico



Kbase P105449: ProDataSets: How to define a query for a child table of a Data-Relation
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   6/17/2005
Status: Unverified

GOAL:

How to define a query for a child table of a Data-Relation?

GOAL:

How to prepare a query that references DATA-SOURCE's ProDataSet target buffers?

GOAL:

How to use a query similar to "FOR EACH <table#1>, EACH <table#2> OF <table#1>" where <table#2> is a target buffer of the DATA-SOURCE's ProDataSet?

FIX:


Normally a query is defined for each top-level parent table but it is also possible to define a query for a child table of a Data-Relation.

/* Sample Code */
DEFINE TEMP-TABLE ttSalesRep NO-UNDO LIKE salesRep.
DEFINE TEMP-TABLE ttCustomer NO-UNDO LIKE customer.
DEFINE QUERY qSalesRep FOR SalesRep.
DEFINE QUERY qCustomer FOR Customer, ttSalesrep.
DEFINE DATASET dset for ttSalesRep, ttCustomer.
DEFINE DATA-SOURCE dsSalesRep FOR QUERY qSalesRep.
DEFINE DATA-SOURCE dsCustomer FOR QUERY qCustomer.

QUERY qSalesRep:QUERY-PREPARE("for each salesrep").
QUERY qCustomer:QUERY-PREPARE("for each customer, each ttSalesrep where customer.salesrep = ttsalesrep.salesrep").
BUFFER ttSalesRep:ATTACH-DATA-SOURCE(DATA-SOURCE dsSalesRep:HANDLE).
BUFFER ttCustomer:ATTACH-DATA-SOURCE(DATA-SOURCE dsCustomer:HANDLE).
DATASET dset:FILL().
FOR EACH ttSalesRep:
DISPLAY ttSalesRep.salesrep.
FOR EACH ttCustomer OF ttSalesRep:
DISPLAY ttCustomer.Name.
END.
END.