在存储过程中有: SELECT 字段1,字段2 into fileds,table FROM 表1,现在我需要在接下来要实现这样的功能:SELECT fileds FROM table(这里的fileds ,table 是前面一个Select中的结果),请问这个在过程中该怎们实现,谢谢。

解决方案 »

  1.   

    动态sqltemp_sql:='SELECT '|| fileds||' FROM '||table;
    execute immadiate temp_sql;如果是要赋值给变量temp_a,就
    execute immadiate temp_sql into temp_a;
      

  2.   

    上面写错了,应该是execute immediate
      

  3.   

    动态sql
    sql='select '||fileds||' from '||table;
    execute immediate sql
            bulk collect into lt_bwm110;
    --定义
    type bwm110_rec is record(
                fileds varchar2(200)
            );        type bwm110_t is table of bwm110_rec index by binary_integer;
            lt_bwm110        bwm110_t;