Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I avoid explicitly naming columns in sql query?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00680574
Message ID:
00680737
Vues:
29
>It wouldn't work for cursors under VFP7 because it doesn't allow long field names truncation by ALTER TABLE command.

Thanks, I thought about it too. Perhaps the only way then to insert into new table record by record.

Do you see something better? (Asumming that the original cursor could not be created with the correct structure).

>>This is not my code, but the code by my colleague:
>>
>>		IF USED(justname )
>>			SELECT &justname
>>		ELSE
>>			USE (ojc.curtable) in 0 EXCL  && Reopen table to do the alter table
>>			SELECT &justname
>>			*wait window 'table not there'  && nl  temporary handling.
>>		ENDIF
>>	lnumflds=afields(fldlistall,justname )  && Get the list of fields in array fldlist
>>	DIMENSION  lfldlist(lnumflds)
>>	idx=0
>>		
>>	FOR i=1 to lnumflds
>>		IF '_A'$fldlistall(i,1)
>>			idx=idx+1
>>			lfldlist(idx)=fldlistall(i,1)
>>		ENDIF
>>		
>>	ENDFOR
>>	lnumchgflds=idx
>>	IF lnumchgflds>0
>>		*Wait window nowait 'Number of unclear fields are '+ALLTRIM(STR(lnumchgflds))
>>		starttime = seconds()
>>		FOR i=1 to lnumchgflds
>>			newname=left(lfldlist(i),AT('_A',lfldlist(i))-1)
>>			ALTER TABLE (tblname) RENAME COLUMN (lfldlist(i)) TO (newname)
>>		
>>		ENDFOR
>>
>>		*wait window nowait "ALTRTABL: Total time = " + str(m.endtime - m.starttime, 10, 4)
>>		endtime = seconds()
>>		*wait window nowait "ALTRTABL: Total time = " + str(endtime - starttime, 10, 4)
>>	ENDIF
>>
>>This code works on tables only. I guess, you can adjust it to work with cursors.
>>
>>
>< snip >
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform