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: Lun Wing San (Oracle) <wslun_at_qrcsun.qrc.org>
Date: 1997/02/14
Message-ID: <33053F69.58CA@qrcsun.qrc.org>#1/1

Maureen T. English wrote:

> 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.
>
> I have thought of creating a temporary table, and of having 12 select
> statements in the script...I'm just curious if there's a way to
> substitute with what the user inputs.

  You can try to use DBMS_SQL package.

---
Name   : Lun Wing San (Certified Oracle Database Administrator)

Title  : Oracle Application Developer of Hong Kong Productivity Council
         Oracle Database Administrator and System Administrator of QRC
Phone  : (852)27885841

This posting represents the personal opinions of the author. It is not the
official opinion or policy of the author's employer. Warranty expired when you
opened this article and I will not be responsible for its contents or use.
Received on Fri Feb 14 1997 - 00:00:00 CST

Original text of this message

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