Recursive function to calculate the level of an associate in the o

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know what you're thinking, this is someone's homework. I promise you it's
not, although it would be a good idea. Does anyone have a code chunk that I
use/modify to calculate the level of an associate in an organization based on
a table that has the associate id and manager id fields in it.

I recognize that it has to be a recursive function, but I'm drawing blanks
on how to write it.

Any help at all would be appreciated, even if it's just suggestions.

Thanks

Mark
 
pseudo-code


public function GetLevel(l_Associate_Id as long,l_Level as long ) as integer
Dim t_Level as long


... myRec = GetRecord where Id = l_Associate_ID ....
' I'm not going to pseudocode out that part of it.


if (myRec!Manager_id = null) then
t_level = l_level + 1
else
t_level = getLevel(myRec!Manager_id,l_level +1)
end if

getLevel = t_level


end function
 
Back
Top