Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UNION clause GO BOOM
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
UNION clause GO BOOM
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01570728
Message ID:
01570728
Vues:
73
Hi Gang!

In getting rid of duplicate records in a table, are there any real world limitations in using the UNION clause in the SQL statement....

like...
LPARAMETERS lcFile

*TMT 04/09/13 Now clean up each table of duplicated records
*start with CHART - text which is the worst
*Create a temporary Cursor to hold the data from the table
CREATE CURSOR csrTempTable (col1 C(250), col2 C(250), col3 C(250), col4 C(250), col5 C(250), col6 C(250), col7 C(250), col8 C(250))
*Move the Chart text file into the csrTempTable cursor
lnHandle = FOPEN(lcFile)
IF lnHandle > 0
	DO WHILE NOT FEOF(lnHandle)
		lcString = FGETS(lnHandle,2001)		&& Get the 2000 characters of the string, up to the carriage return
		*Put the string in the row of csrTempTable
		IF NOT EMPTY(lcString)
			APPEND BLANK IN csrTempTable
			REPLACE col1 WITH SUBSTR(lcString,1,250),    col2 WITH SUBSTR(lcString,251,250),  col3 WITH SUBSTR(lcString,501,250),  col4 WITH SUBSTR(lcString,751,250)
			REPLACE col5 WITH SUBSTR(lcString,1001,250), col6 WITH SUBSTR(lcString,1251,250), col7 WITH SUBSTR(lcString,1501,250), col8 WITH SUBSTR(lcString,1751,250)
		ENDIF 
	ENDDO 
ENDIF 
FCLOSE(lnHandle)
*Now UNION it to itself to remove duplicate rows.....
SELECT * FROM csrTempTable ;
	UNION ;
SELECT * FROM csrTempTable INTO CURSOR csrDupesRemovedTable
*Now put this data back into the text file, removing the data from the text file first....
DELETE FILE (lcFile)
lnHandle2 = FCREATE(lcFile)
SELECT csrDupesRemovedTable
DO WHILE NOT EOF()
	lcString = col1 + col2 + col3 + col4 + col5 + col6 + col7 + col8
*TMT 04/11/2013 - These strings should only by 1600 chars long per BRD	
	lcString = LEFT(lcString,1600)	
	FPUTS(lnHandle2,lcString)
	SKIP 
	lcString = ''
ENDDO 
FCLOSE(lnHandle2)
RETURN 
Seems to work fine, but I worry about LARGE tables coming in, and MEMORY problems.......... ever had it to crash this way using UNION ??

Thanks!
Tommy Tillman A+ NetWork+ MCP
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform