Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Table (Treeview)
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01120782
Message ID:
01120792
Views:
30
Basicaly you could use recursive function/method to get all info from that table. Unfortunately it is almost imposible to use SELECTs in there, somethimg like that:
Let say you have Table_a with following structure
Key   ParentKey GroupName
 I        I        C(50)
and that table has order by ParentKey
SELECT Table_A
SET ORDER TO ParentKey  


CREATE CUROSOR MyCursorForInfo (structure here, don't forget to put some Group field(s))
GetInfoFromThatTable()


FUNCTION GetInfoFromThatTable(lnKey)
   LOCAL lnRecNo
   SELECT Table_A
   IF VARTYPE(lnKey) # [N] && If the type of key field is Numeric of course
      GO TOP
      && All main keys must have parent key = 0
      SCAN WHILE ParentKey == 0 && Scan for MainKeys If you have order
           lnRecNo = RecNo()
           **** Get Info from Product table for that Key
           INSERT INTO MyCursorForInfo ......
           GetInfoFromThatTable(Table_A.Key)
           GOTO lnRecNo
      ENDSCAN
   ELSE
      SEEK m.lnKey
      SCAN WHILE ParentKey == m.lnKey
           lnRecNo = RecNo()
           **** Get Info from Product table for that Key
           INSERT INTO MyCursorForInfo ......
           GetInfoFromThatTable(Table_A.Key)
           GOTO lnRecNo
      ENDSCAN
   ENDIF

RETURN

Something like that.





>Hi friends,
>
>I use to create one table for each information like this:
><pre>
>Table_A                Table_B                Table_C
>ID_A  1-------+        ID_B   1--------+      ID_C
>GroupName     |        SubGroupName    |      ProductName
>              +----N   ID_A            +---N  ID_B
>
>
>This way is easy to get the products that are part of some subGroup or Group. But I have a problem here, because I limited it to 3 levels (Group / SubGroup / Product).
>
>Now I have a problem that I can't say 3 or 5 or 9 levels. So, I think I have to do that:
>
>Table_A               Table_C
>ID_A  1-------+---+   ID_C
>GroupName     |   |   ProductName
>ID_A_Main  N--+   +---N  ID_A
>
>
>So, I can add any number of levels I want. And I can't add a Product for a Group that has a "Main Group". Until here, no problem.
>
>My question is: After users add a lot of groups, they will want to get some information about one major group or any other level. Beside that, they will want to print a report divided by Group / SubGroup / SubSubGroup / ... / Product.
>
>Said that, I have no idea how handle it! Anybody can help me?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform