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



Birgitta Hauser wrote:

For example:
If %Parms >= 3 or %Addr(Parm3) <> *NULL;
//3rd parameter is passed
EndIf;


This code is NOT valid if your program is called from ILE. From ILE you MUST change that 'or' to be an 'and'. Otherwise it's not valid.

When it called from SQL, I don't know if it's valid. Birgitta says it is, but I'm HIGHLY skeptical.

#1 -- since we know SQL doesn't pass a descriptor, we know that %PARMS isn't valid. So why check it?! We already know this IF statement isn't valid from ILE, so why include %PARMS in the check?

#2 -- How would SQL know that there's a 3rd optional parameter in your RPG program, and therefore set the 3rd address to null?! All SQL knows about the procedure is what you put in the 'create function' statement. It doesn't know about the 3rd parameter, so it can't know that it should pass a null address.

I think what Birgitta sees is that when she runs her code, she sees that %PARMS = -1, and %ADDR(Parm3) = *NULL. She assumes that this will always be the case. And she's right, 99.99% of the time! But she's relying on uninitialized memory in a random spot in the computer's memory. If that uninitialized memory happens to be an invalid pointer, then it'll work the way she wants. And that'll be the case most of the time, since it's unlikely that randomly encountered memory will happen to be a valid pointer. However, in the one-in-a-million chance where it is a valid pointer, the code will fail.

When I've discussed this situation with IBMers who work with the database, they've suggested using a different parameter (now i'm trying to remember what it is... the "specific name" parameter, maybe?) to determine which of the overloaded procedures was called.

Personally, I wouldn't try to have more than one overloaded routine call the same RPG subprocedure. Instead, I'd line them up more like this:

SQL routine: JDEDD(varchar(4), numeric(29, 9))
calls RPG: JDEDD1.

SQL routine: JDEDD(varchar(4), numeric(29, 9), varchar(1))
calls RPG: JDEDD2.

Then on the RPG side, have JDEDD1 call JDEDD2 and pass a default value for the extra parameter.

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.