type charArray is table of varchar2(200) index by binary integer;
theCursor sys_refcursor;
dataArray charArray;sSQL := 'select * from table_name'; open theCursor for sSQL;loop
    fetch theCursor into dataArray; -- 问题在这里, 我不知道取出的记录有多少个字段, 怎么搞?
    if theCursor%notfound then
        exit;
    end if;
    for i in 1 .. dataArray.count loop
        dbms_output.put_line(dataArray(i));
    end loop;
end loop;
 
不知道table的字段数的情况下, 想实现动态查找. 请高手指点下

解决方案 »

  1.   

    问题是, 不知道返回的列数. 怎么fetch
      

  2.   

    或者已经知道列数, 如何能动态fetch? 因为每个表都不一样啊. 
      

  3.   

    或者说已经知道列数, 但是如何动态fetch ? 因为每个表的列数都不同
      

  4.   

    那你建一个存储表名及字段的表,将你自己需要的表名及字段名以数据形式存储起来!然后写一个游标读每一条数据将表字段名取出来!
    举一个例子!
    table_name  colum_name
     1           123
     1           456
     1           789
     2           321
     2           345
      

  5.   

    oracle  里已经有这个视图了, user_tab_columns;