您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Oracle中的游标循环

Oracle中的游标循环

解决与第二种方法相关的问题,您需要使用

游标变量和打开游标并获取数据的显式方式。它不是

允许在FOR循环中使用游标变量:

declare
  l_sql varchar2(123);        -- variable that contains a query
  l_c   sys_refcursor;        -- cursor variable(weak cursor). 
  l_res your_table%rowtype;   -- variable containing fetching data  
begin
  l_sql := 'select * from your_table';

  -- Open the cursor and fetching data explicitly 
  -- in the LOOP.

  open l_c for l_sql;

  loop
    fetch l_c into l_res;
    exit when l_c%notfound;   -- Exit the loop if there is nothing to fetch.

     -- process fetched data 
  end loop;

  close l_c; -- close the cursor
end;

了解更多

Oracle 2022/1/1 18:45:25 有331人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶