Problem using dataset and fill method with outer-join query

Posted by ccleaud on 17-Sep-2010 00:50

Hi!

I've got a mistake while i'm using fill method from prodataset.

I'm building a prodataset with 2 temp-tables. One of them is filling from a query with outer-join.(tthab).

In the database, there is no record of boi_habmen to join with boi_appl. But after fill call It seems that a record of boi_habmen exist for each record of boi_appl. In fact all common fields of both of table are filled whereas other fields still empty.

Why does common fields are filled? How can I resolve it?

Thanks a lot.

Ps:

I'm using 10.1A .

Here is my code :

DEFINE BUFFER bboiappl FOR boi_appl.

DEFINE TEMP-TABLE ttboiappl NO-UNDO LIKE boi_appl.

DEFINE TEMP-TABLE tthab NO-UNDO LIKE boi_habmen.

DEFINE DATASET pds FOR ttboiappl, tthab.

DEFINE QUERY q FOR bboiappl, boi_habmen.

DEFINE DATA-SOURCE dsboiappl  FOR boi_appl.

DEFINE DATA-SOURCE dshabmen   FOR QUERY q.

/* Attaching DataSource */

BUFFER ttboiappl:ATTACH-DATA-SOURCE(DATA-SOURCE dsboiappl:HANDLE).

BUFFER tthab:ATTACH-DATA-SOURCE(DATA-SOURCE dshabmen:HANDLE).

/* Prepare Query */

QUERY q:HANDLE:QUERY-PREPARE("for each bboiappl , first boi_habmen of bboiappl outer-join.").

/* Populate ProDataSet */

DATASET pds:FILL().

/* CleanUp */

CLOSE QUERY q.

BUFFER ttboiappl:DETACH-DATA-SOURCE().

BUFFER tthab:DETACH-DATA-SOURCE().

FOR EACH ttboiappl:

    DISPLAY ttboiappl.

    FOR EACH tthab OF ttboiappl:

        DISPLAY tthab.

    END.

END.

Here are my results :

I've got this :

ttboiappl :

CODAPPL : FFFF

TITLE : xxxxxx

tthab:

CODAPPL : FFFF

otherfields : ?

Instead of this :

ttboiappl :

CODAPPL : FFFF

TITLE : xxxxxx

tthab:

CODAPPL : ?

otherfields : ?

Regards,

All Replies

Posted by Admin on 17-Sep-2010 02:41

It's a combination of how outer-join queries return the result and the mapping done by the DATA-SOURCE object.

You are not providing a custom mapping between the database buffer fields and the temp-table buffer fields (additional parameters of the ATTACH-DATA-SOURCE method). So the DATA-SOURCE will roll it's own mapping and that mean it will take the mapping for the common fields from the first buffer / table.

The outer-join will also return records in the parent table (bboiappl) when there is no child table (tthab).

And because the mapping of the common fields is by default taken from the first buffer I'd say what you are describing is expected behavior.

In fact all common fields of both of table are filled whereas other fields still empty.

I'd assume that also the uncommon fields from the first buffer are filled.

Think of copying the joined (no matter if outer-join or inner-join) like creating a record in the temp-table in the same way as you'd see them on screen in a browser connected to the same joined query.

If you do not want records in ttboiappl when there is no tthab, use no outer-join with the query.

I'm using 10.1A .

That's historic. Any chance to update? ProDatasets and other language element have greatly improved.

This thread is closed