Re: SQL question - doing select from (determined at run time)
Posted in 2000
david_henry@my-deja.com wrote:
>
> what I would LIKE to do is something like
>
> create table tables_names(
> code int,
> name char(50)
> );>
> insert into table_names values(1,'database@server:table');>
> select * from (select name from table_names where code=1);>
> which would be the same as
>
> select * from database@server:table;>
> I'm stymied by that fact that the FROM clause must be a table name and I
> can't use a sub-query.
> Any ideas? I'm using dynamic server V7.31.
That sort of SQL is too dynamic -- you have to list the exact table in
the query. You could build a query string in ESQL/C or ODBC or JDBC and
then prepare it, and so on -- that would work. But that's the only
option.
I assume that in a 9.x server, you could write a UDR to do what you
want,
but the database itself won't handle it.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"