test1表中的ind_字段的值是test2表中的字段名,我想用存储过程实现将test1表中的数据一条一条地插入test2中,有点像列转行,但是原问题比这个复杂的多,**但是好像变量值不能作为insert into test2的字段名**,这个位置提示'virtual column not allowed here' ,但是为甚么变量可以作为select 的字段名呢,怎么解决我这个问题,动态sql没用,11g的pivot指标不治本,那个大神帮我从语法或者写机制这方面看看能不能解决啊
create or replace procedure count_to_ is
cursor recos is select * from test1;
resid_ varchar2(32);
indexva_ number;
name_ varchar2(32);
begin
for reco in recos loop
resid_:=reco.id_;
name_ :=reco.ind_;
indexva_:=reco.val_;
begin
insert into test2(id_,name_ ) values (resid_,indexva_);
end;
end loop;
end ;