× 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.



Hi Sam,

Thanks for pointing that out. But as you also note, it drops into CALL_FETCH when COUNTER = 7, which means it was called with CALLTYPE=0, which is the puzzling part. I was expecting a CALLTYPE of 1, and no subsequent calls.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx>/


On 11/11/2013 2:05 PM, Sam_L wrote:
This probably isn't the complete answer...

In CALL_FETCH you are setting SQLSTT after you DSPLY it. The display of
SQLSTT when COUNTER = 6 is 00000. When COUNTER = 7 SQLSTT is 02000,
presumably from it being set in the previous CALL_FETCH.

That said, I don't see why when COUNTER = 7 you are falling into CALL_FETCH.

I believe you get the CALL_CLOSE after you send back SQLSTT = 02000.

Sam



On 11/11/2013 2:03 PM, Peter Dow wrote:
I'm trying out user defined table functions based on Scott Klement's
example at
http://www.scottklement.com/presentations/RPG%20User%20Defined%20Functions%20%26%20Table%20Functions.pdf


My code is at http://code.midrange.com/399002eaaa.htm.

The interesting thing is that my UDTF only gets called with a call type
of -1 (open) and 0 (fetch), but never 1 (close).

I tried creating the function without the NO FINAL CALL, which
theoretically means my UDTF should have been called with a call type of
-2 (startup) and 2 (final) as well as the open/fetch/close, but still
only got called on open and fetch. I have a counter that's incremented
each time the function is called, and put in DSPLYs like this

0045.00 dsply ('STARTUP: ' + %editc(CallType:'L') + ' ' + SQLSTT
+ ' '
0046.00 + %editc(Counter:'L') + ' '
0047.00 + %editc(parmIn:'L'));

to see what was happening and ran it from the green screen STRSQL just
to keep it simple and this is what I got:

STRSQL

select * from table(UDTF1(1)) as t
SELECT statement run complete.

DSPLY OPEN...: 1- 00000 1 1
DSPLY FETCH..: 0 00000 2 1
DSPLY FETCH..: 0 00000 3 1
DSPLY FETCH..: 0 00000 4 1
DSPLY FETCH..: 0 00000 5 1
DSPLY FETCH..: 0 00000 6 1
DSPLY FETCH..: 0 02000 7 1

....+...
PARMOUT
2
3
4
5
******** End of data ********


STRSQL

select * from table(UDTF1(2)) as t
SELECT statement run complete.

DSPLY OPEN...: 1- 00000 8 2
DSPLY FETCH..: 0 00000 9 2
DSPLY FETCH..: 0 02000 10 2

....+...
PARMOUT
******** End of data ********


STRSQL

select * from table(UDTF1(3)) as t
SELECT statement run complete.

DSPLY OPEN...: 1- 00000 11 3
DSPLY FETCH..: 0 00000 12 3
DSPLY FETCH..: 0 02000 13 3

....+...
PARMOUT
******** End of data ********

DSPLY OPEN...: 1- 00000 14 4
DSPLY FETCH..: 0 00000 15 4
DSPLY FETCH..: 0 02000 16 4

....+...
PARMOUT
******** End of data ********

Anyone have an idea what's going on? Is it because I'm calling it from
STRSQL? It occurred to me that maybe the close and final calls happen
when I sign off, so I did a SIGNOFF *LIST, but the resulting job log did
not show anything after the last FETCH.

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx>/



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.