Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fancy SQL on child table
Message
De
28/09/2006 17:39:08
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01157978
Message ID:
01157998
Vues:
25
>I just tested to build a SELECT with so many JOINs as the MAX() number of Synonyms in Synonym table. Something like:
>
>CREATE CURSOR Test  (Fld1 I)
>CREATE CURSOR Test1 (Fld1 I, FLd2 M)
>FOR asd = 1 TO 76
>    INSERT INTO Test  VALUES (asd)
>    INSERT INTO Test1 VALUES (asd%4+1, REPLICATE([a],asd))
>NEXT
>SELECT MAX(test) AS test;
> FROM (SELECT Fld1, COUNT(*) AS test;
>       FROM Test1;
>       GROUP BY Fld1) Tbl1;
>INTO CURSOR crsTest
>
>lcStr  = [SELECT Test.Fld1,MAX(]
>lcJoin = []
>FOR lnFor = 1 TO crsTest.Test
>    lcStr = lcStr + IIF(lnFor>1,[+],[]) + [NVL(","+ALLTRIM(Tbl]+TRANSFORM(lnFor)+[.Fld2),"")]
>    lcJoin = lcJoin + [ LEFT JOIN Test1 Tbl]+TRANSFORM(lnFor)+[ ON Test.Fld1 = Tbl]+TRANSFORM(lnFor)+[.Fld1]
>NEXT
>lcStr  = lcStr +  [) AS TestMe FROM Test ]+lcJoin+[ GROUP BY Test.Fld1 INTO CURSOR crsTte]
>_cliptext =lcStr
>&lcStr
>
>But this almost block my computer :o), in VFP working with NATIVE tables :-).

Thanks, but as I mentioned in the other message, this is under OleDb so I am looking for SQL only approach such as having everything in one SQL instead of doing one to get the styles and 76 other SQLs to get the synonyms.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform