Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Substitution of column names
> 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.
>
If you're using sqlplus to run your script, try:
SELECT FUND, ORGN, ACCT, TOTAL_&1_BUDG FROM MYTABLE;
and call it using the following command line:
sqlplus -s user/passwd @myscript month
Else, if you're in some other tool, try using DBMS_SQL package to issue the statement.
-- Aram Meguerian aram_at_uninet.com.br ------------------------------------------------------------------- "There's no such a thing as a free lunch in the Universe." Lazarus Long Notebook's, Lazarus Long from Time enough for love, by Robert A. Heinlein ------------------------------------------------------------------- I don't work at Unisys, it is just my Internet Provider, so don't blame it for anything I have just said. -------------------------------------------------------------------Received on Sat Feb 15 1997 - 00:00:00 CST