×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
I'm coding an RPG program that extracts data from a list API. In this
case, its QZLSLSTI to list share names on the system.
I'm very new to this, so I'm following an example where the author placed
all functions in an exported sub-procedure. His example used a file, so its
somewhat simpler than what I'd like to do. A UDTF function is called once
for the open, and then multiple times for the fetch, and one more time for
the close. Since I'm processing a list API, pointer data to the user space
is created during the "open", and then paged through using pointer offsets
during the "fetch", and finally the user space is deleted during the
"close".
I'm having some trouble with variables between the calls, I think. Since
everything is under the subprocedure definition, nothing is a global
variable or static. The pointers to the user space seem to need to be
"static", so I made them static, but my offset index counter does not seem
to need to be static for some reason. Sometimes if I execute the SQL to
read from this table more than once, I get no results, which I'm assuming
is because of static variable not being reset, because if I sign out and
back in, things work again.
How should I be managing the memory when coding this API to SQL UDTF?
if CallType=call_open;
// Create user space
.......
// Call list server info API
.......
// Assign header pointer to user space
callp QUSPTRUS(US
:USH_p);
ZL_p=USH_p+USH.QUSOLD;
elseif CallType=call_fetch;
// Assign pointer to API data
idx1+=1;
// Return EOF if end of list
if idx1>=USH.QUSNBRLE;
SQLSTT='02000';
return;
else;
iPath=ZL.PathName;
iShare=ZL.ShareName;
ZL_p+=USH.QUSSEE;
endif;
elseif CallType=call_close;
callp QUSDLTUS(US
: errc0100);
clear USH;
clear ZL;
dealloc USH_p;
dealloc ZL_p;
clear idx1;
clear US;
*INLR=*on;
endif;
return;
end-proc;
___________________________________
Darren Strong
Dekko
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.