Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Table with records 'inheriting' from parent
Message
De
07/03/2006 09:32:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/03/2006 13:29:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01101776
Message ID:
01102057
Vues:
17
>Hi,
>
>I posted the following in the .NET forum but it's essentially a SQL query problem so I thought I'd try here as well:
>--------------->
>Assume a table where each row contains the specification for a rectangle but which also may 'inherit' from a parent row. E.g.:
>
>ID     ParentID   Top    Left   Width    Height    Color
>1      0          10     10     100      100       White
>2      1          null   null   200      null      null
>3      2          null   null   null     null      Red
>4      1          20     20     null     null      Green
>* where non-null values override the parent value. This means ID 3 would be:
>                  10     10     200      100       Red
>* ID 4 would be:
>                  20     20     100      100       Green
>* etc
>
>I had this coded in VFP using recursion to 'walk' back up the tree to the root record and then build the final spec by unwinding back down. Any suggestion on how to implement this using ADO/SQLServer (with as much as possible in SQL since this data may also be accessed by other front ends)?
>
>Bear in mind that the example above is a (gross) over-simplification of the actual table structure and that the nesting levels will often be deeper...
>
>TIA,
>Viv

Viv,
SQLServer2005? If so also check new CTE support (I guess not otherwise you might also use C# to write a procedure).
http://msdn2.microsoft.com/en-us/library/ms190766.aspx
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform