Using dataset of buffers of temp-tables passed with binding

Ian S

New Member
Hi everyone,

I have a dataset which I am passing to another procedure using BIND. In that procedure, I need to define a dataset on a subset of the first dataset's temp-tables; however, Progress does not let me put the same buffer in two datasets so I must define the new dataset on new named buffers of the old temp-tables. However, when I access the handle of the named buffer, Progress is telling me that the buffer is not a member of a dataset.

Here are my procedures:

Proc1.p:

Code:
DEFINE TEMP-TABLE ttShifts NO-UNDO 
    FIELD shiftid AS INT
    FIELD emp AS CHAR.

DEFINE TEMP-TABLE ttTasks NO-UNDO 
    FIELD taskid AS INT
    FIELD shiftid AS INT.

DEFINE DATASET dsShifts
    FOR ttShifts, ttTasks
    DATA-RELATION relTask FOR ttShifts, ttTasks
        RELATION-FIELDS(ttShifts.shiftid, ttTasks.shiftid) NESTED.

DEFINE VARIABLE lcJson AS LONGCHAR NO-UNDO.
DEFINE VARIABLE hProc2 AS HANDLE NO-UNDO.

ASSIGN lcJson = '~{"dsShifts":~{"ttShifts":[~{"shiftid":101,"emp":"Stewart","ttTasks":[~{"taskid":333,"shiftid":101}]}]}}'.

DATASET dsShifts:READ-JSON("LONGCHAR", lcJson).

RUN proc2.p PERSISTENT SET hProc2.
RUN bindDsShifts IN hProc2 (INPUT DATASET dsShifts BIND).
RUN runProc IN hProc2.
DELETE PROCEDURE hProc2.
proc2.p:

Code:
DEFINE TEMP-TABLE ttShifts NO-UNDO REFERENCE-ONLY
    FIELD shiftid AS INT
    FIELD emp AS CHAR.

DEFINE TEMP-TABLE ttTasks NO-UNDO REFERENCE-ONLY 
    FIELD taskid AS INT
    FIELD shiftid AS INT.

DEFINE DATASET dsShiftsExt
    REFERENCE-ONLY
    FOR ttShifts, ttTasks
    DATA-RELATION relTask FOR ttShifts, ttTasks
        RELATION-FIELDS(ttShifts.shiftid, ttTasks.shiftid) NESTED.

DEFINE BUFFER bfShifts FOR ttShifts.
DEFINE DATASET dsShifts FOR bfShifts.

PROCEDURE bindDsShifts:
    DEFINE INPUT PARAMETER DATASET FOR dsShiftsExt BIND.
END.

PROCEDURE runProc:
    DEFINE VARIABLE hDsShifts AS HANDLE NO-UNDO.
    DEFINE VARIABLE hBuf AS HANDLE NO-UNDO.
    ASSIGN 
        hDsShifts = DATASET dsShifts:HANDLE
        hBuf = hDsShifts:GET-BUFFER-HANDLE (1).
    MESSAGE VALID-HANDLE(hBuf:DATASET) VIEW-AS ALERT-BOX.
    /* here I expect YES but I see NO */
END.
Can someone explain to me why at the end, the hBuf:DATASET is not a valid handle?

(In my actual code, I am trying to do ATTACH-DATA-SOURCE which fails because the buffer is supposedly not part of a dataset.)

I am running OpenEdge 11.4.
 
Last edited:

Cecil

19+ years progress programming and still learning.
I know this won't help you, but this code works.

I did find this KBASE Progress KB - Runtime error 12378 when using the BIND option with a temp table

Code:
DEFINE TEMP-TABLE ttShifts NO-UNDO
    FIELD shiftid AS INT
    FIELD emp AS CHAR.

DEFINE TEMP-TABLE ttTasks NO-UNDO 
    FIELD taskid AS INT
    FIELD shiftid AS INT.
/*                                                                    */
/* DEFINE DATASET dsShiftsExt                                         */
/*     REFERENCE-ONLY                                                 */
/*     FOR ttShifts, ttTasks                                          */
/*     DATA-RELATION relTask FOR ttShifts, ttTasks                    */
/*         RELATION-FIELDS(ttShifts.shiftid, ttTasks.shiftid) NESTED. */

DEFINE BUFFER bfShifts FOR TEMP-TABLE ttShifts.

/* DEFINE DATASET dsShifts FOR bfShifts. */
DEFINE DATASET dsShifts FOR ttShifts, ttTasks.

/* PROCEDURE bindDsShifts:                                  */
/*     DEFINE INPUT PARAMETER DATASET FOR dsShiftsExt BIND. */
/* END.                                                     */

PROCEDURE runProc:
    DEFINE VARIABLE hDsShifts AS HANDLE NO-UNDO.
    DEFINE VARIABLE hBuf AS HANDLE NO-UNDO.
    
    CREATE ttShifts.
    CREATE ttTasks.
    
    
    ASSIGN
        hDsShifts = DATASET dsShifts:HANDLE.
        
        MESSAGE hDsShifts:TYPE SKIP
                "VALID-HANDLE:" VALID-HANDLE(hDsShifts) SKIP
                "NUM-BUFFERS:" hDsShifts:NUM-BUFFERS    SKIP
                "NUM-TOP-BUFFERS:" hDsShifts:NUM-TOP-BUFFERS  SKIP
                "NUM-REFERENCES:" hDsShifts:NUM-REFERENCES SKIP
                "NUM-RELATIONS:" hDsShifts:NUM-RELATIONS SKIP
                "RELATIONS-ACTIVE:" hDsShifts:RELATIONS-ACTIVE
                VIEW-AS ALERT-BOX.
        
         hBuf = hDsShifts:GET-TOP-BUFFER(1).
            
        MESSAGE VALID-HANDLE(hBuf)
        VIEW-AS ALERT-BOX.
        
        
/*     MESSAGE VALID-HANDLE(hBuf:DATASET) VIEW-AS ALERT-BOX. */
    /* here I expect YES but I see NO */
    

END.

RUN runProc.
 

Ian S

New Member
The problem is that my runProc represents legacy code that I shouldn't touch. I need to call it with the smaller dataset on one buffer passed in with BIND.

I think the problem is something about BINDing, because when I rewrite it not to use BIND / REFERENCE-ONLY then it works as I expect.
 
Top