2
I have the following situation, my select returns me 3 fields micro (son), descend(descend from the child) and macro(parent) micro and macros fields are integers and can be any number not following default (when I say default I refer to for example micro 2 does not necessarily have 1 as macro can be 3) and I need to fill a treeview
with this information, I can make my query return the records in the orders in which have been added.
My table in the database has the following structure:
ID_HIERARQUIA NUMBER
MICRO NUMBER
DESCR VARCHAR2(300 BYTE)
MACRO NUMBER
POSICAO VARCHAR2(50 BYTE)
I used those insert
's for testing:
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM
HIERARQUIA),'08','EQUIPAMENTO 08','','01');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'04','EQUIPAMENTO 04','08','0101');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'02','EQUIPAMENTO 02','04','010101');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'03','EQUIPAMENTO 03','04','010102');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'05','EQUIPAMENTO 05','08','0102');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'06','EQUIPAMENTO 06','05','010201');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'07','EQUIPAMENTO 07','05','010202');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'01','EQUIPAMENTO 01','07','01020201');
INSERT INTO HIERARQUIA VALUES((SELECT NVL(MAX(ID_HIERARQUIA)+1,1) FROM HIERARQUIA),'09','EQUIPAMENTO 09','07','01020202');
I tried the solution of that link
Where it feeds its list, I adapted it to receive the following query SELECT MICRO, DESCR, MACRO FROM HIERARQUIA ORDER BY POSICAO
But even though he feeds right he only creates the first Ode and doesn’t even add his children, if you can help me I am grateful.
I will try to adapt here, I forgot to inform that it was Windows Forms.. thank you !!!
– Edilson Pereira
The idea is the same only if you look at the Populatenodes method, that you don’t need to change.
– Marco Souza