Dataset BIND error 13011 - What am I doing wrong?

Posted by Lieven De Foor on 16-Jan-2015 09:25

Hi,

I've been struggling for some time now getting a piece of code using dataset BIND option to work. I keep getting errors, and I'm wondering what I'm doing wrong.

I've condensed the problem to a small reproducible, perhaps anyone can indicate where I'm mistaken...

The error I'm receiving is:

BindDataset DataConsumer If BIND used when caller TABLE or DATASET parameter is bound and called parameter ds_Data is also bound, the caller and called parameters must be the same instance. (13011)

Code (also attached in small Eclipse project)

runner.p:

BLOCK-LEVEL ON ERROR UNDO, THROW.

DEFINE VARIABLE DataProvider AS DataProvider NO-UNDO.
DEFINE VARIABLE DataConsumer AS DataConsumer NO-UNDO.

DataProvider = NEW DataProvider().
DataConsumer = NEW DataConsumer(DataProvider:Dataset).
DataConsumer:ShowData().

DataProvider.cls:

BLOCK-LEVEL ON ERROR UNDO, THROW.

CLASS DataProvider:

    { ds_Data.i &ACCESS=PRIVATE }

    DEFINE PUBLIC PROPERTY Dataset AS HANDLE NO-UNDO
    GET:
        RETURN DATASET ds_Data:HANDLE.
    END GET.

    CONSTRUCTOR PUBLIC DataProvider():

        CREATE tt_Data.
        ASSIGN
            tt_Data.Id = 1
            tt_Data.Data = "Hello world!":U.

    END CONSTRUCTOR.

END CLASS.

DataConsumer.cls:

BLOCK-LEVEL ON ERROR UNDO, THROW.

CLASS DataConsumer:

    { ds_Data.i &ACCESS=PRIVATE &REFERENCE-ONLY=REFERENCE-ONLY}

    CONSTRUCTOR PUBLIC DataConsumer(DatasetHandle AS HANDLE):

        BindDataset(DATASET-HANDLE DatasetHandle BIND).

    END CONSTRUCTOR.

    METHOD PUBLIC VOID BindDataset(DATASET ds_Data BIND):

    /* Nothing needed here, just bind with received dataset */

    END METHOD.

    METHOD PUBLIC VOID ShowData():

        FIND FIRST tt_Data NO-ERROR.
        MESSAGE IF NOT AVAILABLE tt_Data THEN "No data to show" ELSE tt_Data.Data
            VIEW-AS ALERT-BOX.

    END METHOD.

END CLASS.

ds_Data.i:

DEFINE {&ACCESS} TEMP-TABLE tt_Data {&REFERENCE-ONLY}
    FIELD Id AS INTEGER
    FIELD Data AS CHARACTER
    INDEX Id IS PRIMARY UNIQUE Id.

DEFINE {&ACCESS} DATASET ds_Data FOR tt_Data.

Posted by Fernando Souza on 16-Jan-2015 12:02

The issue here is that the DataSet it *not* defined as REFERENCE-ONLY, so you cannot bind it. You would have to bind the temp-table, if you need to keep the DataSet definition as is. Or define the DataSet as reference-only and you should be all set.

All Replies

Posted by Fernando Souza on 16-Jan-2015 12:02

The issue here is that the DataSet it *not* defined as REFERENCE-ONLY, so you cannot bind it. You would have to bind the temp-table, if you need to keep the DataSet definition as is. Or define the DataSet as reference-only and you should be all set.

Posted by Lieven De Foor on 17-Jan-2015 02:01

I can't believe I've looked over this... I defined the temp-table as reference only, but not the dataset...

Thanks Fernando!

This thread is closed