Hi guys,
I am wondering if someone could advise me here on something regarding passing data-set between procedures.
If I use the following code snippet as an example .
The code works but I'm wondering whether my input parameters should be dataset-handle as opposed to handles. E.g DEFINE INPUT PARAMETER DATASET-HANDLE htt instead of DEFINE INPUT PARAMETER htt AS HANDLE NO-UNDO.
Can someone please explain the difference between passing a parameter as a dataset handle as opposed to just a handle and which is more correct in this case. My big worry here is when I go to do this using handle insead of DATASET-HANDLE will crash or not work properly if the table data gets too big. But I'd just like to know what the difference is in this case.
As said in the comment in a real scenario read-xml-parameter2 would be in a separate super procedure program on the server, and obviously the variable names etc would be better.
I am wondering if someone could advise me here on something regarding passing data-set between procedures.
If I use the following code snippet as an example .
Code:
DEFINE TEMP-TABLE tt-ch no-undo SERIALIZE-NAME "datarow"
FIELD account-id AS CHARACTER SERIALIZE-NAME "ACCOUNT_NO"
FIELD account-name AS CHARACTER SERIALIZE-NAME "ACCOUNT_NAME"
FIELD phone as character SERIALIZE-NAME "PHONE".
DEFINE DATASET dsCustOrd SERIALIZE-NAME "datarow"
FOR tt-ch.
DEFINE VARIABLE lch AS LONGCHAR NO-UNDO.
DEFINE VARIABLE lOK AS LOGICAL NO-UNDO.
DEFINE VARIABLE vhdl AS HANDLE NO-UNDO.
ASSIGN lch = '
<?xml version="1.0"?>
<data>
<datarow><ACCOUNT_NAME>SP account BTC 1</ACCOUNT_NAME><ACCOUNT_NO>123456789</ACCOUNT_NO><PHONE>1234</PHONE></datarow>
<datarow><ACCOUNT_NAME>SP account CAD 1</ACCOUNT_NAME><ACCOUNT_NO>1234567896</ACCOUNT_NO><PHONE>1234</PHONE></datarow>
<datarow><ACCOUNT_NAME>SP account EUR 1</ACCOUNT_NAME><ACCOUNT_NO>1234567891</ACCOUNT_NO><PHONE>1234</PHONE></datarow>
<datarow><ACCOUNT_NAME>SP account USD 1</ACCOUNT_NAME><ACCOUNT_NO>1234567891</ACCOUNT_NO><PHONE>1234</PHONE></datarow>
</data>'.
ASSIGN vhdl = DATASET dsCustOrd:HANDLE.
EMPTY TEMP-TABLE tt-ch.
RUN read-xml-procedure (INPUT vhdl).
FOR EACH tt-ch NO-LOCK:
DISP tt-ch.
END.
PROCEDURE read-xml-procedure:
DEFINE INPUT PARAMETER htt AS HANDLE NO-UNDO .
run read-xml-procedure2 (INPUT htt).
END PROCEDURE.
PROCEDURE read-xml-procedure2:
DEFINE INPUT PARAMETER htt AS HANDLE NO-UNDO .
lOK = htt:READ-XML('LONGCHAR', lch, 'APPEND', ?, ?, ?, ?).
END PROCEDURE.
The code works but I'm wondering whether my input parameters should be dataset-handle as opposed to handles. E.g DEFINE INPUT PARAMETER DATASET-HANDLE htt instead of DEFINE INPUT PARAMETER htt AS HANDLE NO-UNDO.
Can someone please explain the difference between passing a parameter as a dataset handle as opposed to just a handle and which is more correct in this case. My big worry here is when I go to do this using handle insead of DATASET-HANDLE will crash or not work properly if the table data gets too big. But I'd just like to know what the difference is in this case.
As said in the comment in a real scenario read-xml-parameter2 would be in a separate super procedure program on the server, and obviously the variable names etc would be better.