Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: can I do this in SQL??

Re: can I do this in SQL??

From: <pollachi_at_my-deja.com>
Date: Fri, 22 Oct 1999 17:25:37 GMT
Message-ID: <7uq6md$70c$1@nnrp1.deja.com>


In article <7umovi$t98$1_at_diana.bcn.ttd.net>,   "Jorge" <pumuky22_at_usa.net> wrote:
> Hi everyone, I'm trying to do this select ....
> I have two tables (user_indexes and user_ind_columns) and I want this
> output:
>
> index1 column1 column2 column3
> by row
>
> thanks
>
>

I don't know if you can do it in a single SQL statement, but howabout this?

declare
v_columns varchar2(2000);
begin
for x in (select index_name

            from user_indexes
           where table_name = 'MYTABLE') loop
    v_columns := x.index_name;
    for y in (select column_name
                from user_ind_columns
               where index_name = x.index_name) loop
        v_columns := v_columns || ' ' || y.column_name;
    end loop;
    dbms_output.put_line(v_columns);
end loop;
end;
/

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Oct 22 1999 - 12:25:37 CDT

Original text of this message

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