Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Question

Re: SQL Question

From: Sean Emery <emerys_at_remove_me_jagunet.com>
Date: Thu, 14 Dec 2000 23:28:17 -0500
Message-ID: <2B0E5EBF82AFEE85.3D1AA72D9663EC6A.754B6201424505AB@lp.airnews.net>

You will need to use dynamic sql to accomplish this. You must build the sql statement as a varchar2 and
either use execute immediate in Oracle 8i or DBMS_SQL package in previous versions.

This should get you going in the right direction.

<lsleve_at_my-deja.com> wrote in message news:91bgf7$h7n$1_at_nnrp1.deja.com...
> Considering the following example;
>
> create table mytables (
> table_nameschar(20),
> reference char(30));
> /
> insert into mytables values
> ('TableX','first');
> /
> insert into mytables values
> ('TableY', 'second');
> /
> create tableTableX (
> C1 char(20));
> /
> insert into TableX values
> ('Oracle Corporation');
> /
>
> I need a single query that will extract a tablename from the mytables
> field and shove it into a select statement with the from table being
> the result of the query on mytables. I attempted the following to
> acomplish this:
> select C1 from (select table_names from mytables where reference
> = 'first');
>
> This produced the following output:
> select C1 from (selecttable_names from mytables where reference
> = 'first')
> *
> ERROR at line1:
> ORA-00904: invalid column name
>
> How is this accomplished and what did I do wrong?
>
> LSleve
>
>
>
>
>
> Sent via Deja.com
> http://www.deja.com/
Received on Thu Dec 14 2000 - 22:28:17 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US