Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Variable number of fields in SELECT clause?
On 17 Jan 2002 08:34:33 -0800, robin_at_topniveau.net (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?
Please 'revert' to dynamic sql.
Hth
Sybrand Bakker, Senior Oracle DBA
To reply remove -verwijderdit from my e-mail address Received on Thu Jan 17 2002 - 11:39:23 CST