declare 
strReturn CursorType;
strSql varchar2(100);
begin
  strSql := 'select * from test';
  open strReturn for strSql;
end;问题1:我想定义一个游标,,之后得到返回值
问题2:不用游标 用EXECUTE IMMEDIATE 执行 strSql 能不能得到返回值呢?????
注意:不用存储过程,方法!!!
ORACLE不太会,,,,跪求哥们帮下帮!!!!!!!!!!

解决方案 »

  1.   

    ORACLE有表变量这么个东西吗?
      

  2.   

    oRACLE有表变量这个东西吗?   把结果直接放到表变量里面
      

  3.   


    --可以,給你個例子
    --設置屏幕顯示
    set serveroutput on;
    --測試遊標
    declare
        type cur_type is ref cursor;
        cur cur_type;
        rec emp%rowtype;
        str varchar2(50);
    begin
        str:= 'select ename from emp';
        open cur for str;
        loop
            fetch cur into rec.ename;
            exit when cur%notfound;
            dbms_output.put_line(rec.ename);
        end loop;
    end;
    /
      

  4.   

    rec emp%rowtype;  exit when cur%notfound;
    这2句话是干什么用的啊?????
      

  5.   

    我的表名是test(id ,value )  请问你的程序应该怎么改啊?
      

  6.   


    --設置屏幕顯示
    set serveroutput on;
    --測試遊標
    declare
      type cur_type is ref cursor;
      cur cur_type;
      rec test%rowtype;
      str varchar2(50);
    begin
      str:= 'select id,value from test';
      open cur for str;
      loop
      fetch cur into rec;
      exit when cur%notfound;
      dbms_output.put_line(rec.id||','||rec.ename);
      end loop;
    end;
    /
      

  7.   

    declare
      type cur_type is ref cursor;
      cur cur_type;
      rec test%rowtype;
      str varchar2(50);
    begin
      str:= 'select id,value from test';
      open cur for str;
      loop
      fetch cur into rec;
      exit when cur%notfound;
      dbms_output.put_line(rec.id||','||rec.value);
      end loop;
    end;