Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Substitution of column names
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;
Vijay,
Consultant, Philadelphia.
Received on Wed Feb 12 1997 - 00:00:00 CST