I create variable values like you want by using a report. (We referred to
this as an arrayed variable in scientific related programming).
I create a report called, for example, ArryHold. This report has only 1
detail line and NO columns or variables placed on the report.
There is one variable defined, for example, TEXT vHoldType = (.vHoldType &
HoldType)
(HoldType is a text column in the table that I need an array for. You could
also do this for other type of columns by making appropriate modifications
to the report variable)
To get the desired variable value, use the following example code:
SET V vHoldType TEXT=NULL
OUT C:\HOLDJUNK
PRI ArryHold WHERE ..... ORD BY .....
OUT SCR
Your variable vHoldType now has the desired value. You can modify the
appearance of the array by modifying the report variable, thus, you can
include commers, dashes, extra spaces etc between values.
Also, your WHERE clause and ORD BY can be used to get the desired info and
put it in the correct sequence. To get a new variable value, once you have
this setup, just rerun the code that print the report with any desired WHERE
& ORD BY. I use OUT C:\HOLDJUNK to prevent any info from appearing on the
screen. If you don't intialize the variable, then it will add to the
existing variable. This might be useful in some cases. Think about ways
this could be used.
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