Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question.
Asked: July 25, 2020 - 6:05 am UTC
Last updated: July 27, 2020 - 3:09 am UTC
Version: 12c
Viewed 1000+ times
declare type type_1 is table of user_tab_columns%rowtype; cursor cursor_1(p_table_name varchar2) is select * from user_tab_columns s where s.table_name = p_table_name; v_type_1 type_1; begin open cursor_1('TABLE_NAME_1'); fetch cursor_1 bulk collect into v_type_1; close cursor_1; for i in v_type_1.first .. v_type_1.last loop dbms_output.put_line(' ' || v_type_1(i).column_id || ' ' || v_type_1(i).column_name || ' ' || v_type_1(i).data_type); end loop; end; ------------------------------------------------------------ declare cursor cursor_2(p_table_name varchar2) is select * from user_tab_columns s where s.table_name = p_table_name; begin for i in cursor_2('TABLE_NAME_1') loop dbms_output.put_line(' ' || i.column_id || ' ' || i.column_name || ' ' || i.data_type); end loop; end; ------------------------------------------------------------ declare cursor cursor_3(p_table_name varchar2) is select * from user_tab_columns s where s.table_name = p_table_name; v_type cursor_3%rowtype; begin open cursor_3('TABLE_NAME_1'); loop fetch cursor_3 into v_type; dbms_output.put_line(' ' || v_type.column_id || ' ' || v_type.column_name || ' ' || v_type.data_type); exit when cursor_3%notfound; end loop; close cursor_3; end;
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library