我定义了一个游标:
CURSOR cur_abc IS
execute immediate 'select * from abc where username in(' || parameter || ')';其中Parameter是参数,abc是一个表
但这样是没办法执行,请各位大侠帮帮我,我现在急用呢,谢谢!

解决方案 »

  1.   

    可以用带参游标实现。
    CURSOR cur_abc(as_para varchar2) IS
    select * from abc where username in(as_para);OPEN cur_abc(实参);
      

  2.   

    create or replace procedure ch_table_num( --查看用户下,个表的数据 
    user_name in varchar2,
    errtext out varchar2)
    is                     
    v_num        number(5); 
    cursor  t_cursor is
    select TABLE_NAME  
    from all_tables
    where lower(OWNER) = user_name;  
    t_vale t_cursor%rowtype;
    t_val t_vale.TABLE_NAME%type; 
    begin            
    open t_cursor;  
    loop
    fetch t_cursor into t_val;
        exit when t_cursor%NOTFOUND;
            execute immediate 'select count(*)  from '|| t_val into v_num;
            if v_num > 0 then  
                dbms_output.put_line(v_num||'     '||substr(t_val,1,30));
               end if;
    end loop;
    close t_cursor;
         exception
     when others then
       errtext := SQLERRM;
    end;
      

  3.   

    parameter  varchar2(100);
    CURSOR cur_abc IS
    select * from abc where username in('|| parameter ||' );
    begin
    parameter:='asdf';
    open cur_abc;
    loop 
    fetch cur_abc into var;
    exit when cur_abc%notfound;
    /* process*/
    end loop;