Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I avoid explicitly naming columns in sql query?
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00680574
Message ID:
00680737
Views:
30
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform