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: Referencing columns by their position in a table ??

Re: Referencing columns by their position in a table ??

From: Mark G <someone_at_hot>
Date: Wed, 7 Jul 1999 14:58:10 +0100
Message-ID: <37835aa2.0@145.227.194.253>


If you are constructing a query using dbms_sql, it is possible otherwise no (well not to my knowledge) ;-(

You can pick the column ok...

    select column_name from (select rownum rn, column_name from user_tab_columns
where table_name = 'EMP')
where rn = 2;

COLUMN_NAME



ENAME but you cannot then do this because you can't do a select in a select.

SQL> select empno, (select column_name from   2 (select rownum rn, column_name from user_tab_columns   3 where table_name = 'EMP') name
  4 where rn = 2);
  5 from emp
select empno, (select column_name from

               *
ERROR at line 1:
ORA-00936: missing expression

Mark


Matt Randle wrote in message
<931349966.7333.0.nnrp-12.d4e48d0d_at_news.demon.co.uk>...
>Can anyone tell me if there's a way of specifying a column to retrieve as
>part of a select statement by the position of the column in the table.
>
>For example, a have a table where I know I want to retrieve the 2nd column
>but I do not know what the column is called ??
>
>Thanks,
>
>Matt.
>
>
>
Received on Wed Jul 07 1999 - 08:58:10 CDT

Original text of this message

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