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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Variable number of fields in SELECT clause?

Re: Variable number of fields in SELECT clause?

From: Daniel A. Morgan <damorgan_at_exesolutions.com>
Date: Thu, 17 Jan 2002 14:21:11 +0000
Message-ID: <3C46DDD7.99C49732@exesolutions.com>


 No. Use NDS or DBMS_SQL.

Daniel Morgan

Hamm wrote:

> Hi,
>
> I have the following problem I am trying to solve without reverting to
> dynamic SQL.
>
> Is it possible to have a variable number of fields in the SELECT
> clause, where the number of fields depends on the kind of value the
> field has in a corresponding table.
>
> So lets say I have this table called 'Transactions', each records is
> depicts the settings of a 'transaction'.
>
> FIELD1, FIELD2, FIELD3, FIELD4
> 1 1 0 1
>
> This means I want to make a query where FIELD1, FIELD2 and FIELD4
> appear in the SELECT clause (these fields refer to an other table with
> the exact same field names, ultimately quering that other table for
> only those fields which have been enabled with '1' in this
> transactions table).
>
> I started with something like:
>
> SELECT alias.* FROM (SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME =
> 'TRANSACTIONS' <and has '1' as data>) ALIAS
>
> Obviously the part between brackets is what I cant figure out. Anyway
> easy to refer to the data of all columns in the same statement, trying
> to avoid a massive OR statement?
Received on Thu Jan 17 2002 - 08:21:11 CST

Original text of this message

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