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



Couple options which I was just testing as well :-)

Compile with CLOSQLCSR(*ENDMOD) so it closes the cursor when program exits.

-or-

Once you declare the cursor, issue a close before running your query.

This triggers an SQL. sqlcode=-501 return code, but closes the open cursor before running your query and you can then ignore the close error itself.

I prefer using CLOSQLCSR(*ENDMOD). It’s cleaner.

Let us know how the CTE example works out.

Regards,
Richard Schoen
Web: http://www.richardschoen.net
Email: richard@xxxxxxxxxxxxxxxxx<mailto:richard@xxxxxxxxxxxxxxxxx>

------------------------------
message: 2
date: Sat, 20 Jul 2024 09:53:13 +0200
from: <stefan@xxxxxxxxxx>
subject: RE: Result sets in SQLRPGLE

Daniel wrote:
The more modern approach would be to write a user defined table function (UDTF) - with that you can even use the returned data set inside of CTEs or any SQL construct (aside from updates/deletes).

Thanks a lot for pointing me in this direction - seems to be exactly what I need!

Buck and Richard,

Thanks for pointing out how to return an open cursor. My problem here is that I may end up with an open cursor being left behind. Would like to avoid that.

Thank you for your time and effort!

Best regards

Stefan

--
No trees were killed in the sending of this message, but a large number of electrons were terribly upset.

Stefan Tageson
+46 732 369934
stefan@xxxxxxxxxx



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.