Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Report Trouble
Message
De
30/12/1999 16:31:37
 
 
À
30/12/1999 16:28:22
Jimmy Ditta
Twin City Electronics
Monroe, Louisiane, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00310435
Message ID:
00310690
Vues:
21
>>>>>I understand what's being said, and have given another attempt. Does this look better? (I haven't tested it yet):
>>>>
>>>>Are you intending to sum up the bundle field in each datan table? If so this isn't going to do what you want.
>>>>
>>>>If you need the intermediate summations then you can do it in two steps.
>>>>
>>>>SELECT SUM( data1.bundle ) as sumvar FROM lumber!data1 into cursor bundata WHERE siz = szValue and grade = gdValue and length = 2 union all ;
>>>>SELECT SUM( data2.bundle ) as sumvar FROM lumber!data2 WHERE siz = szValue and grade = gdValue and length = 2 union all ;
>>>>SELECT SUM( data3.bundle ) as sumvar FROM lumber!data3 WHERE siz = szValue and grade = gdValue and length = 2 INTO CURSOR sums
>>>>
>>>>*!* Now you'll see one record with bundle summed for each of the selects
>>>>*!* Now take the total
>>>>
>>>>SELECT SUM( sumvar ) FROM sums INTO CURSOR totalsum
>>>
>>>
>>>why would this be telling me that "variable 'Total22' could not be found" in the tb2 = Total12 + Total22 +... statement?
>>>
>>>SELECT data1.bundle as Total12;
>>>FROM lumber!data1 into cursor bundata2;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data2.bundle as Total22;
>>>FROM lumber!data2;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data3.bundle as Total32;
>>>FROM lumber!data3;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data4.bundle as Total42;
>>>FROM lumber!data4;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data5.bundle as Total52;
>>>FROM lumber!data5;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data6.bundle as Total62;
>>>FROM lumber!data6;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data7.bundle as Total72;
>>>FROM lumber!data7;
>>>WHERE siz = szValue and grade = gdValue and length = 2;
>>>union all;
>>>SELECT data8.bundle as Total82;
>>>FROM lumber!data8;
>>>WHERE siz = szValue and grade = gdValue and length = 2
>>>
>>>
>>>
>>>
>>>tb2 = bundata2.Total12 + bundata2.Total22 + bundata2.Total32 + bundata2.Total42 + bundata2.Total52 + bundata2.Total62 + bundata2.Total72 + bundata2.Total82
>>
>>You're missing the point of what UNION does. At the end of this, you have only one table named bundata2 with one field named Total12. The other field names were all just temporary for the sake of UNION to work. They all got combined into a field called Total12. Check your bundata2 cursor. It probably has 8 records in it.
>
>
>How do I look at the cursor before runtime?

You can't.

Just so you can see what's going on, put a BROWSE statement after the SELECT...UNIONS. This will probably better demostrate to you what's happening with the unions.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform