Hi Marselle,
independent of databases there are some guidelines to use recursions in any
language.
a function calling itself is defined to be recursive.
The VERY thing about is, the recursion has to terminate, so it is good
programming practice
to test at the beginning whether the kriteria for terminating is reached. this
MUST be done
of course BEFORE the recursive call.
Let's make an easy example: compute N! (which is 1*2*3*4 ...* (n-1)*n )
No check is made for an overflow to keep it easy.
To make the above formula recursive, we can say that
n! = (n-1)! * n
or even better
n! = n * (n-1)!
now we can start to program:
function fak(n:integer):integer; // mind: it is fak with an 'a' ;-)
begin
if n <=1 then begin // terminate recursion
result := 1;
end
else begin
result := n * fak(n-1); // the recursion
end;
end;
Mind in the above example, that you are to get an overflow error quite easily!
Happy coding
Bob
> Can anyone direct me to a delphi site that may explain
> how to correctly do recursive processing.
> I am dealing with parent/Child data in a Sql Server
> database.
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/i7folB/TM
--------------------------------------------------------------------~->
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/