我的表是这样定义的 test(id,value)
下面这句话应该怎么改啊--設置屏幕顯示
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;
下面这句话应该怎么改啊--設置屏幕顯示
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;
--設置屏幕顯示
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;
/
set serveroutput on;
--測試遊標
declare
type cur_type is ref cursor;
cur cur_type;
rec emp%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;
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.value);
end loop;
end;zhangandli的 rec.ename应该是rec.value