simple subqueries don't work?
Posted in 2006
Topics: SQL Development & Query Writing
This almost has to be a stupid question, but its so simple I'm finding
it impossible to narrow down an archives search enough to see if its
come up before. Sorry if its old hat.
I'm new to Informix - been databasing on Sybase, Oracle, and SQLServer
for years and I'm trying to cross-apply some basic (or so I thought)
SQL knowledge. The server claims to be "IBM Informix Dynamic Server
Version 10.00.UC3X9". Simple subqueries result in the error "a syntax
error has occurred." Figuring I've stumbled on some minor difference
between Informix SQL and the others, I go on-line to check the manuals
under "Informix Dynamic Server Information Center, V10.x" at
http://www-306.ibm.com/software/data/informix/pubs/library/ids.html.
Here I find the simplistic:
select * from (select * from t)
listed as a valid example, so I type it into my system (replacing t
with the name of a valid table) and get the same helpful "a syntax
error has occurred" error. If I remove the subquery and just select
direct from the table it works fine. Any idea why this example from
the manual doesn't work? Maybe a database option for disallowing
subqueries? Any pointers much appreciated,
- rob.
Some examples in the manuals are for XPS. Some type of subqueries now are not supported with IDS.
dev_nll@yahoo.com wrote:
> This almost has to be a stupid question, but its so simple I'm finding
> it impossible to narrow down an archives search enough to see if its
> come up before. Sorry if its old hat.
>
> I'm new to Informix - been databasing on Sybase, Oracle, and SQLServer
> for years and I'm trying to cross-apply some basic (or so I thought)
> SQL knowledge. The server claims to be "IBM Informix Dynamic Server
> Version 10.00.UC3X9". Simple subqueries result in the error "a syntax
> error has occurred." Figuring I've stumbled on some minor difference
> between Informix SQL and the others, I go on-line to check the manuals
> under "Informix Dynamic Server Information Center, V10.x" at
> http://www-306.ibm.com/software/data/informix/pubs/library/ids.html.
> Here I find the simplistic:
>
> select * from (select * from t)
IDS does not support subqueries in the FROM clause. You can fake it out by
casting the sub-query to a MULTISET. There have been several posters
including Jonathan Leffler who have demonstrated the exact syntax, but, it
goes something like:
select * from TABLE(MULTISET(select * from t))...
Art S. Kagel
> listed as a valid example, so I type it into my system (replacing t
> with the name of a valid table) and get the same helpful "a syntax
> error has occurred" error. If I remove the subquery and just select
> direct from the table it works fine. Any idea why this example from
> the manual doesn't work? Maybe a database option for disallowing
> subqueries? Any pointers much appreciated,
>
> - rob.
>