写一个过程吧,动态结合列 create package test_age as type myrc is ref cursor; end; / create procedure pro(p_table in varchar2,p_rc out test_age.myrc) as cursor t_sor is select COLUMN_NAME from cols where table_name=p_table; str varvhar2(100); begin for v_sor in t_sor loop str:=str||v_sor.column_name; end loop; str:='select '||str||' from '||p_table; open str for p_rc; end; /
那个是得到列属性???
其中的 col1 等是具体的属性列??
要是不知道表中有几列 也不知道属性名呢 那怎么办呢?
create package test_age
as
type myrc is ref cursor;
end;
/
create procedure pro(p_table in varchar2,p_rc out test_age.myrc)
as
cursor t_sor is
select COLUMN_NAME from cols where table_name=p_table;
str varvhar2(100);
begin
for v_sor in t_sor loop
str:=str||v_sor.column_name;
end loop;
str:='select '||str||' from '||p_table;
open str for p_rc;
end;
/