cursor mycursor is --定义游标 select * from all_tab_columns where TABLE_NAME=mytablename ORDER BY column_id; myrecord mycursor%rowtype; --定义游标记录类型 Counter int :=0; begin open mycursor; --打开游标 if mycursor%isopen then --判断打开成功 loop --循环获取记录集 fetch mycursor into myrecord; --获取游标中的记录
if mycursor%found then --游标的found属性判断是否有记录 begin if length(mystring)>0 then mystring:=mystring||‘,‘||myrecord.column_name; else mystring:=myrecord.column_name; end if; end;
else exit; end if;
end loop; else dbms_output.put_line(‘游标没有打开‘); end if; dbms_output.put_line(mystring); close mycursor; end;