Re: SQL Question
Posted in 1997
Strangly this does work in 4GL. I tested with actual data. I would challenge the need for such a construct however, as you would have to make sure that the union returns only one row. In most cases you would then need only one part of the union, and the other part would simply make the whole thing take longer than necessary. Essentially every union need a cursor. Nils johnl@informix.com (Jonathan Leffler) wrote: :What did you try? How hard is it to try a simple test case such as: : :main() :{ : $ int j; : EXEC SQL SELECT Tabid INTO :j FROM SysTables : UNION : SELECT Tabid FROM SysColumns; :} : :to find that the INTO clause goes immediately after the first SELECT list :and prior to the first FROM clause? I tested that this compiled (it won't :run, of course, because it doesn't open a database) with ESQL/C 9.12.UC1, :but I don't think the behaviour would be different in any earlier versions. : :And if you're using I4GL or NewEra (which your syntax suggests is the :case), the same test technique works, does it not? : :Yours, :Jonathan Leffler (johnl@informix.com) #include <witticism.h> : :>From: Kurt Van Wagoner <kurtv@enrich.com> :>Date: Thu, 14 Aug 1997 09:11:31 -0600 :>X-Informix-List-Id: <news.41650> :> :>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. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org