Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual FoxPro
Expertise: Beginner
Jul 8, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Determining Visual Fox Pro Field Length


Is there a way, using Visual FoxPro, to determine the maximum number of characters (not spaces) in a field? I am working with a table that has over 3 million records. I know the field length for lastname and firstname could be reduced to save space. To do this, I need to know the longest firstname and lastname character strings that have letters in them.


Run a single query to find out this information. This is taking advantage of what are called "aggregate" functions in SQL (the MAX aggregate function in this case).

This code creates a cursor with some information and then shows the query to run against it. This will tell you the maximum number of characters in each of the fields, with the trailing spaces trimmed away. Put the code into a PRG file and run it.

create cursor rick(fname c(20),lName c(20))
insert into rick (fname,lname) value ("Rick","Hodder")
insert into rick (fname,lname) value ("Charley","Gunn")
insert into rick (fname,lname) value ("ZipD","DooDah")
select MAX(LENC(RTRIM(fname))) AS sizefname, MAX(LENC(RTRIM(lname))) AS sizelname from rick
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date