Re: Cycle thru columns in table?
From: Kay Kanekowski <kay.kanekowski_at_web.de>
Date: Tue, 9 Mar 2010 06:35:58 -0800 (PST)
Message-ID: <234a9d42-0fce-47d0-a859-af348049b05c_at_g4g2000yqa.googlegroups.com>
Hi,
try this:
inhalt varchar2(30);
Date: Tue, 9 Mar 2010 06:35:58 -0800 (PST)
Message-ID: <234a9d42-0fce-47d0-a859-af348049b05c_at_g4g2000yqa.googlegroups.com>
Hi,
try this:
create table kk_cdom
( first_name varchar2(30),
last_name varchar2(30),
birthday date,
children number);
insert into kk_cdom values ( 'fred', 'flintstone', sysdate-30000,
2);
insert into kk_cdom values ( 'barnie','gröllheimer', sysdate-29900,
3);
select * from kk_cdom;
declare
cursor col is
select COLUMN_NAME from user_tab_columns where table_name = 'KK_CDOM' order by COLUMN_id;
inhalt varchar2(30);
-- begin for spalte in col loop execute immediate ( 'select to_char(' || spalte.column_name || ') from KK_CDOM where rownum < 2' ) into inhalt; dbms_output.put_line ( spalte.column_name || ' : ' || inhalt); end loop; end; / And that is the result: FIRST_NAME : fred LAST_NAME : flintstone BIRTHDAY : 19.01.28 CHILDREN : 2 hth KayReceived on Tue Mar 09 2010 - 08:35:58 CST