Consultor Eletrônico



Kbase P119668: NESTED attribute and READ-XML causes Error 13176 and 13040
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   19/10/2006
Status: Unverified

FACT(s) (Environment):

OpenEdge 10.1x

SYMPTOM(s):

Error 13176 and 13040 is caused by the NESTED attribute and READ-XML method

Unable to create data-relation based on nested Temp-Table elements. (13176)

Unable to infer Temp-Table or dataset schema from XML Data. (13040)

Attributes included in XML element.


DEFINE TEMP-TABLE ttcustomer LIKE customer.
DEFINE TEMP-TABLE ttorder LIKE order.

DEFINE DATASET dssport FOR ttcustomer, ttorder
DATA-RELATION dlorder FOR ttcustomer,ttorder RELATION-FIELDS
(custnum,custnum ) NESTED .

FOR FIRST customer NO-LOCK , FIRST order OF customer :
CREATE ttcustomer.
BUFFER-COPY customer TO ttcustomer.
CREATE ttorder.
BUFFER-COPY order TO ttorder.
END.

DEFINE VARIABLE HDataset1 AS HANDLE NO-UNDO.
DEFINE VARIABLE HDataset2 AS HANDLE NO-UNDO.
DEFINE VARIABLE LCvar AS longCHAR NO-UNDO.

HDataset1 = DATASET dssport:HANDLE.

CREATE DATASET HDataset2.
HDataset1:WRITE-XML("LONGCHAR",LCvar,true ).
HDataset2:READ-XML("LONGCHAR",LCvar,"EMPTY",?,? ).


CAUSE:

This is expected behavior. In the example the customer and order tables are used and the relation is defined on the custnum field. Apart from this fact the other significant issue is that the custnum field is not the only field that exists in both tables. There is also the SaleRep field and the Terms field.In HdataSet2 a relation is infered between parent and child buffers because it is not explicitly specified. But to infer a relation between parent and child buffers you can only have one matching field name between them.


FIX:

Remove some of the matching fields from the buffers. For example:

DEFINE TEMP-TABLE ttcustomer
FIELD CustNum LIKE customer.CustNum
FIELD Country LIKE customer.Country
FIELD Name LIKE customer.Name
FIELD Address LIKE customer.Address
FIELD Address2 LIKE customer.Address2
FIELD City LIKE customer.City
FIELD State LIKE customer.State
FIELD PostalCode LIKE customer.PostalCode
FIELD Contact LIKE customer.Contact
FIELD Phone LIKE customer.Phone
/* FIELD SalesRep LIKE customer.SalesRep */
FIELD CreditLimit LIKE customer.CreditLimit
FIELD Balance LIKE customer.Balance
/* FIELD Terms LIKE customer.Terms */
FIELD Discount LIKE customer.Discount
FIELD Comments LIKE customer.Comments
FIELD Fax LIKE customer.Fax
FIELD EmailAddress LIKE customer.EmailAddress
INDEX custnum IS PRIMARY custnum ASCENDING.

DEFINE TEMP-TABLE ttorder
FIELD Ordernum LIKE order.Ordernum
FIELD CustNum LIKE order.CustNum
FIELD OrderDate LIKE order.OrderDate
FIELD ShipDate LIKE order.ShipDate
FIELD PromiseDate LIKE order.PromiseDate
FIELD Carrier LIKE order.Carrier
FIELD Instructions LIKE order.Instructions
FIELD PO LIKE order.PO
FIELD Terms LIKE order.Terms
FIELD SalesRep LIKE order.SalesRep
FIELD BillToID LIKE order.BillToID
FIELD ShipToID LIKE order.ShipToID
FIELD OrderStatus LIKE order.OrderStatus
FIELD WarehouseNum LIKE order.WarehouseNum
FIELD Creditcard LIKE order.Creditcard
INDEX ordernum IS PRIMARY ordernum ASCENDING
INDEX custnum custnum ASCENDING.

DEFINE DATASET dssport FOR ttcustomer, ttorder
DATA-RELATION dlorder FOR ttcustomer,ttorder RELATION-FIELDS
(custnum,custnum ) NESTED .
FOR FIRST customer NO-LOCK , FIRST order OF customer :
CREATE ttcustomer.
BUFFER-COPY customer TO ttcustomer.
CREATE ttorder.
BUFFER-COPY order TO ttorder.
END.

DEFINE VARIABLE HDataset1 AS HANDLE NO-UNDO.
DEFINE VARIABLE HDataset2 AS HANDLE NO-UNDO.
DEFINE VARIABLE LCvar AS longCHAR NO-UNDO.

HDataset1 = DATASET dssport:HANDLE.
CREATE DATASET HDataset2.
HDataset1:WRITE-XML("LONGCHAR",LCvar,true ).
HDataset2:READ-XML("LONGCHAR",LCvar,"EMPTY",?,? ).