Consultor Eletrônico



Kbase P148643: 4GL/ABL: How to exclude childless parent table nodes from the XML document generated by a ProDataSe
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/1/2009
Status: Unverified

GOAL:

4GL/ABL: How to exclude childless parent table nodes from the XML document generated by a ProDataSet object handle WRITE-XML( ) method?

GOAL:

How to include only the parent table that have children in the XML file generated by a ProDataSet object handle WRITE-XML( ) method?

GOAL:

How to restrict the customer table nodes generated by a ProDataSet object handle WRITE-XML( ) method to those that have Orders?

GOAL:

How to have the XML file generated by a ProDataSet object handle WRITE-XML( ) method reflect the INNER-JOIN between the parent and child tables?

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.x

FIX:

The following procedure demonstrates one way of restricting the XML parent nodes to those that have child records. Specifically, this example shows how to restrict the Customer table nodes in the XML document generated by a ProDataSet object handle WRITE-XML method to those customer records that have Orders. For example, if Customer where custnum = 2 has no orders, then there will be no node for that customer:
DEFINE TEMP-TABLE ttcust NO-UNDO LIKE customer.
DEFINE TEMP-TABLE ttord NO-UNDO LIKE order.
DEFINE BUFFER buffOrder FOR order.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hDataSource1 AS HANDLE NO-UNDO.
DEFINE VARIABLE hDataSource2 AS HANDLE NO-UNDO.
DEFINE DATASET dcustord FOR ttcust, ttord
DATA-RELATION drelcustord FOR ttcust, ttord NESTED
RELATION-FIELDS (custnum, custnum).
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(BUFFER customer:HANDLE, BUFFER buffOrder:HANDLE).
CREATE DATA-SOURCE hDataSource1.
CREATE DATA-SOURCE hDataSource2.
hDataSource1:QUERY = hquery.
hDataSource2:ADD-SOURCE-BUFFER(BUFFER order:HANDLE,"custnum").
hQuery:QUERY-PREPARE("FOR EACH customer WHERE CustNum < 5, each buffOrder of customer").
BUFFER ttcust:ATTACH-DATA-SOURCE(hDataSource1).
BUFFER ttord:ATTACH-DATA-SOURCE(hDataSource2).
DATASET dcustord:FILL().
DATASET dcustord:WRITE-XML("FILE","CustomerOrder.xml").