Passing empty DataSet to Appserver

675 Views Asked by At

I'm trying to create a single proxy query to our appserver, which uses the following parameters:

editTest.p

DEFINE TEMP-TABLE TT_Test NO-UNDO
    BEFORE-TABLE TT_TestBefore
    FIELD fieldOne LIKE MyDBTable.FieldOne
    FIELD fieldTwo LIKE MyDBTable.FieldTwo
    FIELD fieldThree LIKE MyDBTable.FieldThree
.

DEFINE DATASET dsTest FOR TT_Test.

/* Parameters */
DEF INPUT-OUTPUT PARAM DATASET FOR dsTest.

The idea is that the program would call this procedure in 2 different ways:

  • with passed dataset parameter: read passed dataset and update db according to it's changes
  • without passed dataset parameter/unknown/unset: fill TT_Test and return dataset to client for editing

Is there any way to create a proxy like this? Easy solution would be to separate the get and insert,modify,delete to 2 own proxy files, so the client would always first get the dataset and then pass it for for the second one. However, I'd like to implement this functionality into this one file.

The key is to use the datasets, so the changes made to the data can be updated almost automatically.

1

There are 1 best solutions below

2
On

Instead of using the dataset itself as the parameter, use a dataset handle. You can then make it null for your 2nd condition. Adding on to your example, procedure testProc will display a message "yes" when the dataset is passed in via the handle, and "no" when null is passed in.

DEFINE TEMP-TABLE TT_Test NO-UNDO
    BEFORE-TABLE TT_TestBefore
    FIELD fieldOne LIKE MyDBTable.FieldOne
    FIELD fieldTwo LIKE MyDBTable.FieldTwo
    FIELD fieldThree LIKE MyDBTable.FieldThree
.

DEFINE DATASET dsTest FOR TT_Test.


PROCEDURE testProc:

    DEFINE INPUT-OUTPUT PARAMETER DATASET-HANDLE phDataSet.

    MESSAGE VALID-HANDLE(phDataSet) VIEW-AS ALERT-BOX.

END.


DEFINE VARIABLE hTest AS HANDLE NO-UNDO.

/* Pass in a dataset. */
hTest = DATASET dsTest:HANDLE.
RUN testProc (INPUT-OUTPUT DATASET-HANDLE hTest).

/* Pass in null. */
hTest = ?.
RUN testProc (INPUT-OUTPUT DATASET-HANDLE hTest).