declare
strReturn CursorType;
strSql varchar2(100);
begin
strSql := 'select * from test';
open strReturn for strSql;
end;问题1:我想定义一个游标,,之后得到返回值
问题2:不用游标 用EXECUTE IMMEDIATE 执行 strSql 能不能得到返回值呢?????
注意:不用存储过程,方法!!!
ORACLE不太会,,,,跪求哥们帮下帮!!!!!!!!!!
strReturn CursorType;
strSql varchar2(100);
begin
strSql := 'select * from test';
open strReturn for strSql;
end;问题1:我想定义一个游标,,之后得到返回值
问题2:不用游标 用EXECUTE IMMEDIATE 执行 strSql 能不能得到返回值呢?????
注意:不用存储过程,方法!!!
ORACLE不太会,,,,跪求哥们帮下帮!!!!!!!!!!
--可以,給你個例子
--設置屏幕顯示
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;
/
这2句话是干什么用的啊?????
--設置屏幕顯示
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;
/
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;