Jim,
I can thing of 2 ways to try to do this.
As Ben said, you can't do a sub-select into a variable directly, but you
could just put the sub select code in a variabe and use &varname to execute
it.
The other way would be to do it the old fashon way with a loop. Try
something like:
set var vstring text=null
declare c1 cur for select gl_acct where ...
open c1
fetch c1 into v1
while sqlcode <> 100 then
if vstring is null then
set var vstring = .v1
else
set var vstring = (.vstring + ',' + .v1)
endif
fetch c1 into v1
endwhile
Troy
===== Original Message from [EMAIL PROTECTED] at 6/21/01 1:07 am
>Jim,
>
>Can't do that. Someone recently requested something like it as an
>enhancement. You can select from another table based on the
>values returned by the sub-select, but those values can't be stored
>in a variable.
>
>Ben Petersen
>
>On 22 Jun 2001, at 9:36, Jim Limburg wrote:
>
>> G-Day all
>>
>> I started out this morning to do what I thought a simple thing. To build
>> a sub-select statement that would return into a variable the values in a
>> column that are not null and distinct even if it is in the column more
>> than once..
>>
>> I want the variable to contain 6090,7010,4050,1320,1590 ... and so on...
>>
>> The data in the columns is text/12 and here is what I attempted so far.
>>
>> SELECT gl_acct INTO vg_gl_acct FROM gl_pur_01 WHERE gl_acct IN +
>> (SELECT gl_acct FROM gl_pur_01 where gl_acct is not null and limit=1)
>>
>> Thanks
>> Jim Limburg
>>