Re: SQL Question
Posted in 1997
Claus Samuelsen — — source: Informix-list mailing list archive (1991-1998)
Kurt Van Wagoner wrote:
>
> How do you do a select into variable with a union?
> i.e.
> I know
> select id, desc
> into var1, var2
> from tab1> But I do not know;
> select id, desc
> from tab1
> union
> select id2, desc2
> from tab2;>
> Any help would be appreciated.
Thats easy.
You should use a cursor:
DECLARE union_curs CURSOR FOR "select .... union select ..."
OPEN union_curs
FETCH union_curs INTO var1, var2 .. varn
remember to check sqlca.sqlcode
best regards
Claus Samuelsen
Sysdeco Danmark A/S