在oracle的存储过程中,如果获得查询语句的列数和各个列名?
如果能获得列的类型,最好了。谢谢!!

解决方案 »

  1.   

    select * from user_tab_columns where table_name =?
      

  2.   

    select column_name,data_type,DATA_LENGTH from user_tab_cols 
    where table_name=upper('tbname')
      

  3.   

    select * from user_tab_columns where table_name =?
      

  4.   

    我不是要表,而是要查询语句;
    例如:
    select * from user u , department d where u.department_id = d.id而且,我的语句会是动态sql,返回的列数不定,列名不定。
    谢谢。
      

  5.   

    只能自己做串解析了。不过select语句千变万化,想找个适应各种情况的解析不容易
      

  6.   

    lz要列数和列名有什么用处吗?一般都是通过查询语句取数据!不明白lz取它的目的是什么呢?
      

  7.   


    select column_name  from dba_tab_columns where table_name=表名 order by column_id;
      

  8.   

    你可以用动态sql先用查询语句创建一个表。然后在user_tab_columns里查询表的字段。
    这样就不用解析查询语句的串了。
      

  9.   

    execute immediate 'create table tablename as '||查询语句字符串;
    然后从user_tab_columns里按tablename查询字段信息