Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Substitution of column names
In article <330202BF.6CA0_at_orca.alaska.edu>, "Maureen T. English" <snmte_at_orca.alaska.edu> 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;
>
> Every month the select statement changes. Is there a way to have the
> user input the cycle (01, 02, ... 12) and then insert what the user
> inputs into the column name? Otherwise, every month I have to edit the
> script to change the 01s to 02s, or the 02s to 03s, etc.
>
(Sans error checking)
accept cyclenum prompt: 'Enter the cycle number (01 - 12): ' select FUND, ORGN, ACCT, TOTAL_&cyclenum_BUDG
FROM MYTABLE;
gary -=- visit The C Programmers' Reference -=- http://users.southeast.net/~garyg/C_ref/C/c.html The AVENUE Programmers' Class Requests http://users.southeast.net/~garyg/class.htmReceived on Sat Feb 15 1997 - 00:00:00 CST