Attach-data-source with query

Posted by damienk on 28-Jun-2013 05:16

Hi,

I have a Dataset with 2 tables :

DEFINE DATASET ds_AB FOR tt_tableA,tt_tableB

    DATA-RELATION dr_AB FOR tt_tableA,tt_tableB

    RELATION-FIELDS (tt_tableA.code , tt_tableB.code).

In ds_AB_read.p :

DEFINE OUTPUT PARAMETER DATASET FOR ds_AB.

DEFINE QUERY qr_AB FOR TABLEA, TABLEB.

DEFINE DATA-SOURCE src_ab       FOR QUERY qr_AB .

QUERY qr_AB :QUERY-PREPARE( "FOR EACH TABLEANO-LOCK, EACH TABLEBOF TABLEA BLABLABLA" ).

BUFFER tt_tableA:ATTACH-DATA-SOURCE (DATA-SOURCE src_ab :HANDLE).

DATASET ds_AB :FILL().

When I execute the code, I have this message : FILL requires an attached data-source for buffer <name>, or an active before-fill callback procedure. (11874)

If you do not have a data-source for a particular buffer in a dataset, you can set its FILL-MODE to NO-FILL, and provide your own 4GL to fill it.  If you want it automatically filled, you must provide some means via a callback or a data-source object that is mapped to the buffer.

I add this

DEFINE DATA-SOURCE src_b       FOR TABLEB .

and

BUFFER tt_tableB:ATTACH-DATA-SOURCE (DATA-SOURCE src_b :HANDLE).

then I have this message "Buffer <name> may be in only one data-source at a time.  Use different buffers for the same table. (12298)"

Because a data-source and its database buffer must be in a one to one relation, you can have only one data-source for a particular buffer for a particular database table.  However, you can have many buffers for the same database table, so just create or define a second buffer for this data-source on the same database table.   Also, a data-source can relate to more than one database table, and you need a unique buffer for each database table.

Any tips ?

All Replies

Posted by Wouter Dupré on 28-Jun-2013 05:20

Hi,

Thank you for your email. I'm currently out of the office on vacation. I will return on July 1, 2013. During my absence I will have no or very limited access to email and phone. For urgent matters, please call our office general number +32 15 30 77 00.

Warm regards,

Wouter

--

Wouter Dupré

Sr. Systems Engineer

Progress Software NV

A. Stocletlaan 202 B | B-2570 Duffel | Belgium

Office +32 (0) 15 30 77 46 | Mobile +32 (0) 478 50 00 49

Posted by wrpkm2 on 28-Jun-2013 06:42

DEFINE OUTPUT PARAMETER DATASET FOR ds_AB.

DEFINE QUERY qr_AB FOR TABLEA, TABLEB.

DEFINE DATA-SOURCE src_ab       FOR QUERY qr_AB .

DEFINE BUFFER TABLEB2 FOR TABLEB.

DEFINE DATA-SOURCE src_b         FOR TABLEB2.

BUFFER tt_tableB:ATTACH-DATA-SOURCE(DATA-SOURCE src_b:HANDLE).

QUERY qr_AB :QUERY-PREPARE( "FOR EACH TABLEA NO-LOCK, EACH TABLEB OF TABLEA BLABLABLA" ).

BUFFER tt_tableA:ATTACH-DATA-SOURCE (DATA-SOURCE src_ab :HANDLE).

DATASET ds_AB :FILL().

The problem is in the buffers, above you will see that I have created a 2nd buffer for TABLEB as TABLEB2, if you use the new buffer in the QUERY then you will also have to change the table name in the QUERY-PREPARE.

So for simplicity i used TABLEB2 for the standalone DATA-SOURCE.

Posted by damienk on 03-Jul-2013 04:03

Thanks!

This thread is closed