RELATION-FIELDS

Posted by rbf on 27-Jul-2009 04:39

Is it me or is the documentation on the RELATION-FIELDS of a ProDataSet incorrect? The documentation states:

This is the syntax for a field-mapping-phrase:


Syntax
RELATION-FIELDS (parent-field1, child-field1 [, parent-fieldn, child-fieldn ] …)

The first field of each pair of RELATION-FIELDS is from the parent buffer, the second field is
from the child.

This works well when the field names are the same, but when they are not the same we found
that it actually seems to be the other way around. This is also suggested by the example
on page 1-38 of the 10.2A ProDataSet documentation:

DEFINE DATASET myRecurs FOR ttEmployee
DATA-RELATION r1 FOR ttEmployee, ttEmployee
RELATION-FIELDS (cEmployee, cManager) RECURSIVE.

Now this is a recursive example, and so is our own case, but clearly the order used here is

child-field, parent-field

When I search the documentation and PKB there is not a word on this matter. So my questions are:

- Is the documentation correct?
- Is the exception a recursive relation? (If so, why is that not documented as such)
- Has anyone run into this before or am I missing something else?

-peter

All Replies

Posted by Admin on 27-Jul-2009 08:13

I've never used a PDS recursively so have no experience there.

With a pairs list you can prefix with a table name.  Does that also apply to relation fields and does that have any effect.

In the following example in production code I have it's parent, child.

DEFINE DATASET dsparty{&ext} FOR ttparty{&ext},

                           ttpostProperty{&ext},

                           ttphysproperty{&ext}

    Data-Relation dr-party-postal for ttparty{&ext}, ttpostproperty{&ext}

        relation-fields (postalid, propertyid)

    Data-Relation dr-party-physprop for ttparty{&ext}, ttphysproperty{&ext}

        relation-fields (physpropid, propertyid).

The recursive employee example is not as obvious what going on.  You can say that an employee has a manager and so the employee is the parent.

It's late here and I too tired to dwell on it, but I would wonder how the where clause is constructed or something else that would indicate who is the parent.

Posted by Håvard Danielsen on 27-Jul-2009 08:58

DEFINE DATASET myRecurs FOR ttEmployee
DATA-RELATION r1 FOR ttEmployee, ttEmployee
RELATION-FIELDS (cEmployee, cManager) RECURSIVE.

Now this is a recursive example, and so is our own case, but clearly the order used here is

child-field, parent-field

I did not check the doc, but I would assume that cEmployee is the primary key of the Employee table and thus the parent key field and that cManager is the "self relation field" and thus the child field.

Posted by ojfoggin on 10-Aug-2009 05:12

I recently set up my first ProDataSet with a relation using the documentation.

The tables were oporder and opgohead.

Oporder is the parent and opgohead is the child.

The fields that are related are...

oporderopgohead
kcokco
kdoctypekorddoctype
knotekordnote

The syntax I used is...

def dataset ds-document for tt-oporder, tt-opgohead
    data-relation for tt-oporder, tt-opgohead
    relation-fields (kco, kco,
                         kdoctype, korddoctype,
                         knote, kordnote).

This worked fine for me and the relation was the correct way round.  I had a query attached to tt-oporder and attached the tt-opgohead table to the database direct.

When I ran the fill it populated as I expected it to.

Oliver

Posted by rbf on 10-Aug-2009 06:56

Thank you for your input.

This issue is still open but the developer who ran into it is currently on holidays for two weeks.

It seems to focus on recursive cases.

I will get back later.

This thread is closed