str:='select * from '||变量|| 'where ...';

解决方案 »

  1.   

    表名、字段名不定的,动态拼凑sql语句
      

  2.   

    excute immediate select * from tablename col1=变量;
      

  3.   

    要用动态的sql
    declare
    str varchar2(200);
    sql varchar2(200);
    begin
    str:='aa';
    sql:='select '||str||'from '||str||' where aa='''||str||''' and ....';
    execute immediate sql;
    end;
      

  4.   

    用了动态的SQL,还有错误?????    v_tab_name :='sales';
        v_str:='select count(*) from '||v_tab_name;
    /*  dbms_output.put_line(v_str);*/ ----这个显示select count(*) from sales(没有;号)
        execute immediate v_str;
     end loop;
    end;ORA-06564: 对象 DATA_FILE_DIR 不存在
    ORA-06512: 在line 31
      

  5.   

    这个错误不是动态SQL本身的问题.ORA-06564 object string does not existCause: The named object could not be found. Either it does not exist or you do not have permission to access it.Action: Create the object or get permission to access it.