Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fancy SQL on child table
Message
 
À
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:
01157999
Vues:
31
>>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.


Yes, I know that. But you could Execute first select to get MAX() Synonyms, then build the SELECT String (I suppose in .NET) and then back to OLEDB to run builded string.
AFAIK there is no easy method to concatenate strings with SELECT command, always have to use functions.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform