Hi Scott
This sounds exactly what would be required in this instance.
I am in the middle of doing something else at the moment, so I haven't researched what you mentioned, but any idea where I could find some information on what you are talking about?

Alan Shore
Programmer/Analyst, Direct Response
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill

-----Original Message-----
From: Scott Klement [mailto:midrange-l@xxxxxxxxxxxxxxxx]
Sent: Thursday, March 15, 2012 1:20 PM
To: Midrange Systems Technical Discussion
Cc: Alan Shore
Subject: Re: Creating an SQL UDF on a procedure

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.

Disclaimer: This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.

This thread ...


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

This mailing list archive is Copyright 1997-2020 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].