Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fixing field length in SQL Select command
Message
From
28/11/2001 21:04:35
 
 
To
28/11/2001 17:02:40
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00587219
Message ID:
00587303
Views:
19
>Is it possible to set the field lenght of a field when using the SQL Select command. What I need to do is insert 4 lines into a table based on existing values in the table and calculated values. The fourth line is the sum of the first three lines. Number of fields is dynamic so I am using macro substitution to create the lines. In the original table the format of the numeric fields is 12. When I do my Select commands I get different lengths for the fields. Is there any way around this?
>
>I am thinking of using arrays. I there is an easy way to print the values of the arrays? How about adding them (short of the brute force method of a For loop).


Claude --

If you're creating a new cursor/table and using syntax like SELECT 2 AS nField, pad the numeric values to the left with leading zeroes, place a decimal point to separate the whole from fraction, and pad the value to the right with 0's to the number of decimal places you need.

For example, the following clause will create a numeric field of 12 bytes in length with 2 decimal places.
SELECT 000000002.00 AS nField
If you're creating this from scratch, the following expression will provide the appropriate format (code the mask -- the sequence of 9's, for the format you want):
CHRTRAN (TRANSFORM (nField, "999999999.99"), " ", "0")
To print arrays, I think the easiest thing is to create a table, then copy the array to that table (APPEND FROM ARRAY) -- the native data structure for reports.

I'm not sure if that's the same issue as you raised first. If it is, your definition of the table will take care of appropriate definition of the fields.

Jay
Previous
Reply
Map
View

Click here to load this message in the networking platform