I've copied the bulk of the VFP8 help entry for sending query results to an
array below. If you look at the output for the company column, the values
are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
Unfortunately, the best I can do is to trim() the appropriate results by
hand after my queries execute. So...is the help entry wrong or am I missing
something?
-Lew

SELECT - SQL is a versatile command for querying tables and can direct query
results to an array.
To send SELECT - SQL query results to an array, specify the INTO ARRAY
clause with an array name. If the array doesn't exist, it is automatically
created. If the array does exist, it is redimensioned automatically to
accommodate the query results.

Example
In the following example, SELECT - SQL directs its query results to an array
named RESULTS:
SELECT DISTINCT a.cust_id, a.company, b.amount ;
FROM customer a, payments b ;
WHERE a.cust_id = b.cust_id INTO ARRAY results

DISPLAY MEMORY LIKE results

RESULTS Priv A TEST
( 1, 1) C "000004"
( 1, 2) C "Stylistic Inc."
( 1, 3) N 13.91 ( 13.91000000)
( 2, 1) C "000008"
( 2, 2) C "Ashe Aircraft"
( 2, 3) N 4021.98 ( 4021.98000000)
( 3, 1) C "000010"
( 3, 2) C "Miakonda Industries"
( 3, 3) N 9.84 ( 9.84000000)

Re: VFP8 Help entry for Arrays and Select - SQL ... Wrong or what? by Fred

Fred
Sun Mar 20 00:07:07 CST 2005

The help example is incorrect. The field width is what you'll get.

--
Fred
Microsoft Visual FoxPro MVP


"Lew" <lew@clsystems.com> wrote in message
news:%239DWNdQLFHA.3500@TK2MSFTNGP14.phx.gbl...
> I've copied the bulk of the VFP8 help entry for sending query results to
> an array below. If you look at the output for the company column, the
> values are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
> Unfortunately, the best I can do is to trim() the appropriate results by
> hand after my queries execute. So...is the help entry wrong or am I
> missing something?
> -Lew
>
> SELECT - SQL is a versatile command for querying tables and can direct
> query results to an array.
> To send SELECT - SQL query results to an array, specify the INTO ARRAY
> clause with an array name. If the array doesn't exist, it is automatically
> created. If the array does exist, it is redimensioned automatically to
> accommodate the query results.
>
> Example
> In the following example, SELECT - SQL directs its query results to an
> array named RESULTS:
> SELECT DISTINCT a.cust_id, a.company, b.amount ;
> FROM customer a, payments b ;
> WHERE a.cust_id = b.cust_id INTO ARRAY results
>
> DISPLAY MEMORY LIKE results
>
> RESULTS Priv A TEST
> ( 1, 1) C "000004"
> ( 1, 2) C "Stylistic Inc."
> ( 1, 3) N 13.91 ( 13.91000000)
> ( 2, 1) C "000008"
> ( 2, 2) C "Ashe Aircraft"
> ( 2, 3) N 4021.98 ( 4021.98000000)
> ( 3, 1) C "000010"
> ( 3, 2) C "Miakonda Industries"
> ( 3, 3) N 9.84 ( 9.84000000)
>



Re: VFP8 Help entry for Arrays and Select - SQL ... Wrong or what? by Anders

Anders
Sun Mar 20 09:19:39 CST 2005

FOR i = 1 TO ALEN(aResults,1)*ALEN(aResults,2)
IF VARTYPE(aResults,M.i)) ='C'
aResults(M.i)=ALLTRIM(aResults(M.i))
ENDIF
NEXT
-Anders

"Lew" <lew@clsystems.com> wrote in message
news:#9DWNdQLFHA.3500@TK2MSFTNGP14.phx.gbl...
> I've copied the bulk of the VFP8 help entry for sending query results to
an
> array below. If you look at the output for the company column, the values
> are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
> Unfortunately, the best I can do is to trim() the appropriate results by
> hand after my queries execute. So...is the help entry wrong or am I
missing
> something?
> -Lew
>
> SELECT - SQL is a versatile command for querying tables and can direct
query
> results to an array.
> To send SELECT - SQL query results to an array, specify the INTO ARRAY
> clause with an array name. If the array doesn't exist, it is automatically
> created. If the array does exist, it is redimensioned automatically to
> accommodate the query results.
>
> Example
> In the following example, SELECT - SQL directs its query results to an
array
> named RESULTS:
> SELECT DISTINCT a.cust_id, a.company, b.amount ;
> FROM customer a, payments b ;
> WHERE a.cust_id = b.cust_id INTO ARRAY results
>
> DISPLAY MEMORY LIKE results
>
> RESULTS Priv A TEST
> ( 1, 1) C "000004"
> ( 1, 2) C "Stylistic Inc."
> ( 1, 3) N 13.91 ( 13.91000000)
> ( 2, 1) C "000008"
> ( 2, 2) C "Ashe Aircraft"
> ( 2, 3) N 4021.98 ( 4021.98000000)
> ( 3, 1) C "000010"
> ( 3, 2) C "Miakonda Industries"
> ( 3, 3) N 9.84 ( 9.84000000)
>
>


Re: VFP8 Help entry for Arrays and Select - SQL ... Wrong or what? by Lew

Lew
Sun Mar 20 21:10:54 CST 2005

Yep, I had the solution, but I wanted to get rid of the bother.
-Lew
"Anders Altberg" <x_pragma@telia.com> wrote in message
news:uc6T4DWLFHA.3184@TK2MSFTNGP09.phx.gbl...
> FOR i = 1 TO ALEN(aResults,1)*ALEN(aResults,2)
> IF VARTYPE(aResults,M.i)) ='C'
> aResults(M.i)=ALLTRIM(aResults(M.i))
> ENDIF
> NEXT
> -Anders
>
> "Lew" <lew@clsystems.com> wrote in message
> news:#9DWNdQLFHA.3500@TK2MSFTNGP14.phx.gbl...
>> I've copied the bulk of the VFP8 help entry for sending query results to
> an
>> array below. If you look at the output for the company column, the values
>> are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
>> Unfortunately, the best I can do is to trim() the appropriate results by
>> hand after my queries execute. So...is the help entry wrong or am I
> missing
>> something?
>> -Lew
>>
>> SELECT - SQL is a versatile command for querying tables and can direct
> query
>> results to an array.
>> To send SELECT - SQL query results to an array, specify the INTO ARRAY
>> clause with an array name. If the array doesn't exist, it is
>> automatically
>> created. If the array does exist, it is redimensioned automatically to
>> accommodate the query results.
>>
>> Example
>> In the following example, SELECT - SQL directs its query results to an
> array
>> named RESULTS:
>> SELECT DISTINCT a.cust_id, a.company, b.amount ;
>> FROM customer a, payments b ;
>> WHERE a.cust_id = b.cust_id INTO ARRAY results
>>
>> DISPLAY MEMORY LIKE results
>>
>> RESULTS Priv A TEST
>> ( 1, 1) C "000004"
>> ( 1, 2) C "Stylistic Inc."
>> ( 1, 3) N 13.91 ( 13.91000000)
>> ( 2, 1) C "000008"
>> ( 2, 2) C "Ashe Aircraft"
>> ( 2, 3) N 4021.98 ( 4021.98000000)
>> ( 3, 1) C "000010"
>> ( 3, 2) C "Miakonda Industries"
>> ( 3, 3) N 9.84 ( 9.84000000)
>>
>>
>



Re: VFP8 Help entry for Arrays and Select - SQL ... Wrong or what? by Paul

Paul
Sun Mar 20 21:42:55 CST 2005

It might work the way you want if you use VFP9 and varchar data type. But
then you'd have to trim all the data before the select anyway.


"Fred Taylor" <ftaylor@mvps.org!REMOVE> wrote in message
news:%23CY1LMRLFHA.3184@TK2MSFTNGP09.phx.gbl...
> The help example is incorrect. The field width is what you'll get.
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>
> "Lew" <lew@clsystems.com> wrote in message
> news:%239DWNdQLFHA.3500@TK2MSFTNGP14.phx.gbl...
>> I've copied the bulk of the VFP8 help entry for sending query results to
>> an array below. If you look at the output for the company column, the
>> values are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
>> Unfortunately, the best I can do is to trim() the appropriate results by
>> hand after my queries execute. So...is the help entry wrong or am I
>> missing something?
>> -Lew
>>
>> SELECT - SQL is a versatile command for querying tables and can direct
>> query results to an array.
>> To send SELECT - SQL query results to an array, specify the INTO ARRAY
>> clause with an array name. If the array doesn't exist, it is
>> automatically created. If the array does exist, it is redimensioned
>> automatically to accommodate the query results.
>>
>> Example
>> In the following example, SELECT - SQL directs its query results to an
>> array named RESULTS:
>> SELECT DISTINCT a.cust_id, a.company, b.amount ;
>> FROM customer a, payments b ;
>> WHERE a.cust_id = b.cust_id INTO ARRAY results
>>
>> DISPLAY MEMORY LIKE results
>>
>> RESULTS Priv A TEST
>> ( 1, 1) C "000004"
>> ( 1, 2) C "Stylistic Inc."
>> ( 1, 3) N 13.91 ( 13.91000000)
>> ( 2, 1) C "000008"
>> ( 2, 2) C "Ashe Aircraft"
>> ( 2, 3) N 4021.98 ( 4021.98000000)
>> ( 3, 1) C "000010"
>> ( 3, 2) C "Miakonda Industries"
>> ( 3, 3) N 9.84 ( 9.84000000)
>>
>
>



Re: VFP8 Help entry for Arrays and Select - SQL ... Wrong or what? by Lew

Lew
Sun Mar 20 21:42:57 CST 2005

..and wouldn't just plain for i = 1 to alen(aResults) be simpler & better?
-Lew
"Anders Altberg" <x_pragma@telia.com> wrote in message
news:uc6T4DWLFHA.3184@TK2MSFTNGP09.phx.gbl...
> FOR i = 1 TO ALEN(aResults,1)*ALEN(aResults,2)
> IF VARTYPE(aResults,M.i)) ='C'
> aResults(M.i)=ALLTRIM(aResults(M.i))
> ENDIF
> NEXT
> -Anders
>
> "Lew" <lew@clsystems.com> wrote in message
> news:#9DWNdQLFHA.3500@TK2MSFTNGP14.phx.gbl...
>> I've copied the bulk of the VFP8 help entry for sending query results to
> an
>> array below. If you look at the output for the company column, the values
>> are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
>> Unfortunately, the best I can do is to trim() the appropriate results by
>> hand after my queries execute. So...is the help entry wrong or am I
> missing
>> something?
>> -Lew
>>
>> SELECT - SQL is a versatile command for querying tables and can direct
> query
>> results to an array.
>> To send SELECT - SQL query results to an array, specify the INTO ARRAY
>> clause with an array name. If the array doesn't exist, it is
>> automatically
>> created. If the array does exist, it is redimensioned automatically to
>> accommodate the query results.
>>
>> Example
>> In the following example, SELECT - SQL directs its query results to an
> array
>> named RESULTS:
>> SELECT DISTINCT a.cust_id, a.company, b.amount ;
>> FROM customer a, payments b ;
>> WHERE a.cust_id = b.cust_id INTO ARRAY results
>>
>> DISPLAY MEMORY LIKE results
>>
>> RESULTS Priv A TEST
>> ( 1, 1) C "000004"
>> ( 1, 2) C "Stylistic Inc."
>> ( 1, 3) N 13.91 ( 13.91000000)
>> ( 2, 1) C "000008"
>> ( 2, 2) C "Ashe Aircraft"
>> ( 2, 3) N 4021.98 ( 4021.98000000)
>> ( 3, 1) C "000010"
>> ( 3, 2) C "Miakonda Industries"
>> ( 3, 3) N 9.84 ( 9.84000000)
>>
>>
>



Re: VFP8 Help entry for Arrays and Select - SQL ... Wrong or what? by Anders

Anders
Mon Mar 21 04:11:29 CST 2005

Indeed it would. Thanks
-Anders

"Lew" <lew@clsystems.com> wrote in message
news:eAOCdgcLFHA.2796@tk2msftngp13.phx.gbl...
> ..and wouldn't just plain for i = 1 to alen(aResults) be simpler & better?
> -Lew
> "Anders Altberg" <x_pragma@telia.com> wrote in message
> news:uc6T4DWLFHA.3184@TK2MSFTNGP09.phx.gbl...
> > FOR i = 1 TO ALEN(aResults,1)*ALEN(aResults,2)
> > IF VARTYPE(aResults,M.i)) ='C'
> > aResults(M.i)=ALLTRIM(aResults(M.i))
> > ENDIF
> > NEXT
> > -Anders
> >
> > "Lew" <lew@clsystems.com> wrote in message
> > news:#9DWNdQLFHA.3500@TK2MSFTNGP14.phx.gbl...
> >> I've copied the bulk of the VFP8 help entry for sending query results
to
> > an
> >> array below. If you look at the output for the company column, the
values
> >> are all trim()/alltrim()'d -- a behavior I'd like to duplicate.
> >> Unfortunately, the best I can do is to trim() the appropriate results
by
> >> hand after my queries execute. So...is the help entry wrong or am I
> > missing
> >> something?
> >> -Lew
> >>
> >> SELECT - SQL is a versatile command for querying tables and can direct
> > query
> >> results to an array.
> >> To send SELECT - SQL query results to an array, specify the INTO ARRAY
> >> clause with an array name. If the array doesn't exist, it is
> >> automatically
> >> created. If the array does exist, it is redimensioned automatically to
> >> accommodate the query results.
> >>
> >> Example
> >> In the following example, SELECT - SQL directs its query results to an
> > array
> >> named RESULTS:
> >> SELECT DISTINCT a.cust_id, a.company, b.amount ;
> >> FROM customer a, payments b ;
> >> WHERE a.cust_id = b.cust_id INTO ARRAY results
> >>
> >> DISPLAY MEMORY LIKE results
> >>
> >> RESULTS Priv A TEST
> >> ( 1, 1) C "000004"
> >> ( 1, 2) C "Stylistic Inc."
> >> ( 1, 3) N 13.91 ( 13.91000000)
> >> ( 2, 1) C "000008"
> >> ( 2, 2) C "Ashe Aircraft"
> >> ( 2, 3) N 4021.98 ( 4021.98000000)
> >> ( 3, 1) C "000010"
> >> ( 3, 2) C "Miakonda Industries"
> >> ( 3, 3) N 9.84 ( 9.84000000)
> >>
> >>
> >
>
>