以水平格式获取 table headers |数据库 |

Fetch table headers in horizontal format | PLSQL |

我有点受困于它没有得到我应该改变的地方以及如何执行

我需要以逗号分隔的水平格式获取特定的 table header

示例: header1,header2,header3

使用示例代码并根据我的需要进行编辑

create or replace getdetails( vtable_name varchar2 , out voutput)
return varchar2
  as 
      v_sql varchar2(40000) :='';
BEGIN
      v_sql ='select listagg(column_name,',') within group (order by column_name) items from user_tab_columns where table_name :=vtable_name;'

EXCEPTION
    when no date_found then retrun '0';
    when others        then retrun '0';
END; 

需要将输出输出到变量中

用select变成:

create or replace function getdetails( vtable_name varchar2 , out voutput)
return varchar2
  as 
      v_columns varchar2(4000) :='';
BEGIN
      select listagg(column_name,',') within group (order by column_name) 
        into v_columns
        from user_tab_columns 
       where table_name = vtable_name;
      dbms_output.put_line (v_columns);
      return v_columns;

EXCEPTION
    when no_data_found then retrun '0';
    when others        then return '0';
END;