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



I think there's a limit in SQL.

Just FYI:
If you are coding a recursion in SQL with Recursive Common Table
expressions, a CYCLE clause can be added between CTE and final SELECT
statement. If this clause is missed in composition with a bi-directional
relationship, you'll will end up in an infinite loop.

If you are coding a recursion in SQL with a hierarchical Query Clause (START
WITH ... CONNECT BY), you need to specify the key word NOCYCLE in
composition with a bi-directional relationship. If this keyword is missed,
the query is NOT executed, but an error message is sent out.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von aec
Gesendet: Monday, 18.2 2013 03:10
An: RPG programming on the IBM i (AS/400 and iSeries)
Betreff: Re: Recursion in RPG

Isn't there a call stack limit for jobs that would prevent infinite
recursion loops anyway?

I think there's a limit in SQL, but the shop where I currently work has has
a standard that bans doing any recursion in SQL. I assume there is a similar
standard for RPG, but haven't had occasion to ask, but I have never had a
situation that seemed to need it. I can't help but think there would almost
always an alternative involving a loop of some kind.

Where you have such a thing, seems to me you could handle it by "stacking"
your state (or "deepness") to variables in storage, without having to call
your same procedure. Recursion might simplify it but it never seemed "right"
to me anyway. Even bills of materials is a matter in my opinion of indexing
"stacks" of data, and looping up and down therein. Presumably that's the way
compiled code handles recursive procedures anyway, including in object
oriented program languages.

---Alan


On 2/14/13 5:24 PM, Rory Hewitt wrote:
I would assume that there *is* a recursion limit, even if it could
never realistically be reached - there has to be a variable somewhere
in the runtime process which keeps track of the current recursion
number, and that variable will eventually overflow. But by that point,
chances are the total memory limit would have been reached.

In one of my recursion processes where I was worried about limits, I
set a global MaxRecurse variable prior to calling the recursive
procedure for the first time, and the procedure increments a global
CurrRecurse variable (also initialized at the start), and compares to
MaxRecurse and drops out if it's gone 'too deep'... Not hard to do.


On Thu, Feb 14, 2013 at 2:32 PM, Buck Calabro <kc2hiz@xxxxxxxxx> wrote:

On 2/14/2013 5:27 PM, Scott Klement wrote:
Hmmm... well, why would there be a hard number? Seems to me, the
nature of a call stack would lend itself to something that doesn't
have a hard number of entries, but rather, a memory limit.

On 2/14/2013 4:21 PM, Buck Calabro wrote:
No wonder Chuck couldn't find a hard number. There does not appear
to be one. The same verbiage is in the 5.4 Reference as well as 7.1.
--buck
Good question! Similar to maximum CPU time used, or maximum DASD
used, an OS might choose to restrict a process to a maximum number of
recursions.
--buck

--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/rpg400-l.




--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.



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.