Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL SELECT Statement - Problem with Field Definition Cha
Message
 
À
08/12/1998 10:33:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00165075
Message ID:
00165565
Vues:
10
John: Man! I really appreciate the help. Thanks a lot! Also, I learned something else while working thru this problem... I can use the SQL statement to SELECT...INTO an ARRAY, and then APPEND FROM the ARRAY. This prevents creating another table on disk as well as preventing the field renaming problem. The code I used follows...
SELECT LdlInput.prodline, ;	&& Copy records to
	LdlInput.dept, ;	&& LdlData Array
	LdlInput.date, ;
	LdlInput.year, ;
	LdlInput.period, ;
	SUM(LdlInput.ladlesqty) AS ladlesqty, ;
	LdlInput.weight ;
	FROM LdlInput ;
	WHERE LdlInput.Weight <> 0 ;
	GROUP BY LdlInput.Weight ;
	ORDER BY LdlInput.Weight ;
	INTO ARRAY LdlData
		
	SELECT Ladles_d	&& APPEND records to Ladles_d.dbf for permanent storage.
	APPEND FROM ARRAY LdlData
>Chuck ---
>
>Change your SELECT statement to:
>
>SELECT prodline, dept, date, year, period, COUNT(ladlesqty) AS ladlesqty, weight FROM LdlInput.dbf WHERE Weight <> 0 GROUP BY Weight ORDER BY Weight INTO TABLE LdlData.dbf
>
>This will store the count() result in a field with the exact same name and will enable your append from command later. The field len difference shouldn't matter.
>
>
>>I program for an iron foundry. I have a table that has daily data entered into it for the weight of each ladle of molten metal that has been poured in the foundry. Some of the weights are identical. For example, today there may be 2 ladles weighing 1873 lbs each, and 3 ladles weighing 1902 lbs each, etc. For EACH ladle that is poured, a record is entered into the table; so that, for the 2 ladles of 1873 lbs mentioned above, you would have 2 individual records stating a Qty of 1, and a Weight of 1873 lbs.
>>
>>I am attempting to use an SQL SELECT statement to gather this data, GROUP the identical weights together, add up (COUNT) the quantities for records with identical weights, and then write these records INTO another TABLE. Once these these records are tabulated in this fashion, I then wish to turn around and APPEND these records into a permanent history file called Ladles_d.dbf.
>>
>>Here's the SQL SELECT statement I'm using...
>>
>>SELECT prodline, dept, date, year, period, COUNT(ladlesqty), weight FROM LdlInput.dbf WHERE Weight <> 0 GROUP BY Weight ORDER BY Weight INTO TABLE LdlData.dbf
>>
>>This works beautifully with the following exception...
>>
>>The field definition for the ladlesqty field (the field on which the COUNT is performed) gets changed in the target LdlData table...
>>
>>
>>Fieldname gets changed from ladelsqty to cnt_ladles
>>Width changes from Numeric 6 to Numeric 10
>>
>>
>>When I then try to APPEND FROM LdlData into Ladles_d.dbf, the permanent history file (which has the same structure as the daily entry table, LdlInput.dbf), all the fields come across except for the ladlesqty field.
>>
>>Obviously, this makes my effort totally useless as I lose the quantity of ladles poured. Any help would be greatly appreciated as I am about to pull my hair out at this point. Thanks, CWH.
Chuck Henry
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform