0
I have a table Categoria
with CategoriaId
of Primary key and CategoriaPaiId
Foreign key with self relationship in CategoriaId
.
I need to create a procedure
listing the category tree.
Assuming I have the categories with their respective subcategories:
Perishables > Beverages > Wines > Red.
On the record Booze, i need it to be returned in the variable &CategoriaSubCategoriaNome
the following string:
Perishables > Beverages.
In the Red record, I need it to be returned in the variable &CategoriaSubCategoriaNome
the following string:
Perishables > Beverages > Wines
That was the trial I imagined:
&isTrue = true
&isAchou = true
do while &isTrue = true
if &isAchou = true
&isAchou = false
for each
where CategoriaId = &CategoriaPaiId
&CategoriaSubCategoriaNome = &CategoriaSubCategoriaNome+ " > " + CategoriaNome
&isAchou = true
endfor
if &isAchou = false
return
endif
endif
enddo
But it’s entering an infinite loop. Any idea?