Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Side by side comparison (strings & local data)
Message
 
 
À
07/01/2004 08:42:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00861648
Message ID:
00865270
Vues:
33
>a) this schema not support characters or memo fields with strings lenght > 2XX

This can be addressed by creating a cursor with a memo field and then union the actual results with it. It would mean creating 2 field selection lists and increase the complexity of the code. If anybody really wants it I will be happy to oblige.

>b) field id and relative index can to be removed using UNION ALL

You are correct removing the ID column would negate the need for the index. However from a performance perspective (on 1,000 rows) there is negligible difference. I had to go over 30,000 rows before seeing a consistent benefit (of only 0.1 second).
*************************************
Function fHoustonBrennan2( cXMLfile )
*************************************
	Local nStart ;
		, cEmptyField, cEmptyFieldList ;
		, cPopulatedField, cPopulatedFieldList ;
		, iField, cFieldName, cDataType, cSql

	If Empty( cXMLfile ) Then
		cXMLfile = "HoustonBrennan2.XML"
	Endif

	nStart = Seconds()

	cEmptyField = ""
	cEmptyFieldList     = ["<Test>  " As cStartCol, ]

	cPopulatedField = ""
	cPopulatedFieldList = ["<Client>" As cStartCol, ]

	For iField = 1 To FCount()
		cFieldName = Field( iField )
		cDataType = Type( cFieldName )
		Do Case
			Case cDataType $ "CM"
				cEmptyField = ["] ;
					+ Space( Len( Evaluate( cFieldName ))) ;
					+ Space( 2 * Len( [<] + cFieldName + [>] ) + 1 ) ;
					+ [", ]
				cPopulatedField = ["<] + cFieldName + [>" + ] ;
					+ cFieldName ;
					+ [ + "</] + cFieldName + [>", ]

			Case cDataType $ "D"
				cEmptyField = ["] ;
					+ Space( Len( Dtoc( {} ))) ;
					+ Space( 2 * Len( [<] + cFieldName + [>] ) + 1 ) ;
					+ [", ]
				cPopulatedField = ["<] + cFieldName + [>" + ] ;
					+ "DtoC(" + cFieldName + ")" ;
					+ [ + "</] + cFieldName + [>", ]

			Case cDataType $ "T"
				cEmptyField = ["] ;
					+ Space( Len( TtoC({} ))) ;
					+ Space( 2 * Len( [<] + cFieldName + [>] ) + 1 ) ;
					+ [", ]
				cPopulatedField = ["<] + cFieldName + [>" + ] ;
					+ "TtoC(" + cFieldName + ")" ;
					+ [ + "</] + cFieldName + [>", ]

			Case cDataType $ "N"
				cEmptyField = ["] ;
					+ Space( Len( Str( Evaluate( cFieldName ) ))) ;
					+ Space( 2 * Len( [</] + cFieldName + [>] ) + 1 ) ;
					+ [", ]
				cPopulatedField = ["<] + cFieldName + [>" + ] ;
					+ "Str(" + cFieldName + ")" ;
					+ [ + "</] + cFieldName + [>", ]

			Case cDataType $ "L"
				cEmptyField = ["] ;
					+ Space( Len( [<] + cFieldName + [> </] + cFieldName + [>] )) ;
					+ [", ]
				cPopulatedField = ["<] + cFieldName + [>" + ] ;
					+ "Transform(" + cFieldName + ")" ;
					+ [ + "</] + cFieldName + [>", ]

			Otherwise
				cEmptyField = ["] ;
					+ Space( Len( Transform( Evaluate( cFieldName ) ))) ;
					+ Space( 2 * Len( [</] + cFieldName + [>] ) + 1 ) ;
					+ [", ]
				cPopulatedField = ["<] + cFieldName + [>" + ] ;
					+ "Transform(" + cFieldName + ")" ;
					+ [ + "</] + cFieldName + [>", ]
		Endcase
		cEmptyFieldList = cEmptyFieldList + cEmptyField
		cPopulatedFieldList = cPopulatedFieldList + cPopulatedField
	Next iField

	cEmptyFieldList = cEmptyFieldList + ["] + Space(9) + [" As cEndCol]
	cPopulatedFieldList = cPopulatedFieldList + ["</Client>" As cEndCol]

	cSql = [Select ] + cEmptyFieldList ;
				+ [ From ] + Alias() ;
				+ [ Into Cursor Temp NoFilter ReadWrite] ;
				+ [ Where RecNo() == 1 ] ;
			+ [ Union All Select ] + cPopulatedFieldList ;
				+ " From " + Alias() ;
				+ " Where .T."
	******
	&cSql.
	******
	Insert Into Temp (cStartCol) Values ( "</Test>" )
	Copy To (cXmlFile) Type SDF
	Use In Temp
	?? Seconds() - nStart
	Modi File (cXMLfile) NoWait
	Return .T.
	Endfunc	&& fHoustonBrennan2().
censored.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform