declare l_tab_name varchar2(32) := 'MY_TABLE'; begin for c1 in (select t.column_name from user_tab_columns t where t.table_name = l_tab_name) loop execute immediate 'select distinct ' || c1.column_name || ' from ' || l_tab_name; end loop; end;
プレ>
declare l_tab_name varchar2(32) := 'MY_TABLE'; begin for c1 in (select t.column_name from user_tab_columns t where t.table_name = l_tab_name) loop execute immediate 'select distinct ' || c1.column_name || ' from ' || l_tab_name; end loop; end;
プレ>