× 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 Alan,

On 3/15/2012 10:36 AM, Alan Shore wrote:
Thanks for your reply Gary I am not too sure whether or not I am
understanding what you are telling me. How can a SQL User Define
Function created over the procedure change the user space when used
as part of a view, or as part of an SQL script?

My apologies... I seem to have missed the start of this discussion. Please be forgiving if I say something that has already been discussed.

If I understand correctly, you are writing an external scalar function that, under the covers, uses RPG's native I/O. And you want to close the files when the function is called the last time in a session.

Have you considered using the SQL "FINAL CALL" functionality? It's a clause you specify on the Create Function statement. When you include this, SQL will pass an additional parameter (an integer) to your function. The parameter is known as "call type", and will contain values indicating "first call" (when you'd open your files), "normal call" (when you do your work -- what you're doing now) and "final call" (where you'd close your files.)

Typically, "final call" is executed the last time a function is needed during the run of an SQL statement. (Or, when the cursor is closed, in a select statement that uses a cursor.)

I don't know if that is adequate for your needs or not -- but, so far, it has been for all of mine. And the caller doesn't need to know or care about adding an extra statement to tell it to close, so that makes the caller's job much easier, too.

Just a thought.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.