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: Substitution of column names

Re: Substitution of column names

From: vijay <vijay_at_prodigy.net>
Date: 1997/02/12
Message-ID: <3302A5FB.2D66@prodigy.net>#1/1

Maureen T. English wrote:
>
> Hi Everyone,
>
> I there a simple way to select a column from a table, based on what
> a user inputs?
>
> My table has the following columns
> FUND
> ORGN
> ACCT
> TOTAL_01_BUDG
> TOTAL_02_BUDG
> TOTAL_03_BUDG
> .
> .
> .
> TOTAL_12_BUDG
>
> My select statement is
> SELECT FUND, ORGN, ACCT, TOTAL_nn_BUDG
> FROM MYTABLE;
>

Hai,

 You can use decode and select the appropriate column as shown:  SELECT FUND, ORGN, ACCT, decode(user_input,1,TOTAL_01_BUDG,

        2, TOTAL_02_BUDG, 3, TOTAL_03_BUDG.....)
        FROM MYTABLE;

 Hope this will help you to solve your problem.

Vijay,
Consultant, Philadelphia. Received on Wed Feb 12 1997 - 00:00:00 CST

Original text of this message

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