oracle的显式游标
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,declare cursor user_cur is select * from my_user; user_row my_user%rowtype; begin open us
千家信息网最后更新 2026年10月31日oracle的显式游标
declare cursor user_cur is select * from my_user; user_row my_user%rowtype; begin open user_cur; loop fetch user_cur into user_row; exit when user_cur%notfound; dbms_output.put_line(user_row.user_id||'----'||user_row.name); end loop; close user_cur; end;
declare cursor user_cur is select * from my_user; row_user my_user%rowtype; begin open user_cur; loop fetch user_cur into row_user; exit when user_cur%notfound; dbms_output.put_line(row_user.user_id||'----'||row_user.name||'----'||row_user.age); end loop; close user_cur;end;
declare cursor row_user is select * from my_user; type my_user_tab is table of my_user%rowtype; /* 定义和表my_user行对象一致的集合类型cur_row_user, 用于存放批量得到的数据 */ cur_row_user my_user_tab; begin open row_user; loop /*从结果集中提取数据,每次提取两行*/ fetch row_user bulk collect into cur_row_user limit 2; /*遍历集合cur_row_user中的数据*/ for i in 1..cur_row_user.count loop dbms_output.put_line(cur_row_user(i).user_id||'----'||cur_row_user(i).name||'----'||cur_row_user(i).age); end loop; exit when row_user%notfound; end loop; close row_user; end;
declare cursor user_cur is select * from my_user; type my_user_tab is table of my_user%rowtype; /* 定义和表my_user行对象一致的集合类型cur_user_cur, 用于存放批量得到的数据 */ cur_user_cur my_user_tab; begin open user_cur; loop /*从结果集中提取数据,每次提取两行*/ fetch user_cur bulk collect into cur_user_cur limit 2; /*遍历集合cur_user_cur中的数据*/ for i in 1..cur_user_cur.count loop dbms_output.put_line(cur_user_cur(i).user_id||'----'||cur_user_cur(i).name||'----'||cur_user_cur(i).age); end loop; exit when user_cur%notfound; end loop; close user_cur; end;
declare cursor user_cur is select * from my_user; begin for cdr in user_cur loop dbms_output.put_line(cdr.user_id||'----'||cdr.name||'----'||cdr.age); end loop; end; /*cursor for loop 不需要特别的申明变量,它可以提取出行对象类型数据*/
declare cursor user_cur is select * from my_user; cdr my_user%rowtype; begin if user_cur%isopen then fetch user_cur into cdr; dbms_output.put_line(cdr.user_id||'----'||cdr.name||'----'||cdr.age); else dbms_output.put_line('游标没有打开'); end if; end;declare cursor user_cur is select * from my_user; cdr my_user%rowtype; begin open user_cur; if user_cur%isopen then loop fetch user_cur into cdr; exit when user_cur%notfound; dbms_output.put_line(cdr.user_id||'----'||cdr.name||'----'||cdr.age); end loop; else dbms_output.put_line('游标没有打开'); end if; end;declare cursor user_cur is select * from my_user; cdr my_user%rowtype; begin open user_cur; loop fetch user_cur into cdr; if user_cur%found then dbms_output.put_line(cdr.user_id||'----'||cdr.name||'----'||cdr.age); else dbms_output.put_line('游标没有打开'); exit; end if; end loop; end;declare /*这里的取值写在declare和begin中都可以*/ v_user_id my_user.user_id%type:='&v_user_id'; /*这里的v_user_id的类型写number和my_user.user_id%type都可以*/ cursor c_my_user(v_user_id my_user.user_id%type) is select * from my_user where user_id=v_user_id; cdr my_user%rowtype; begin open c_my_user(v_user_id); loop fetch c_my_user into cdr; if c_my_user%found then dbms_output.put_line(cdr.user_id||'----'||cdr.name||'----'||cdr.age); else dbms_output.put_line('游标没有打开'); exit; end if; end loop; end;
数据
游标
类型
对象
一致
结果
变量
出行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技名片
湖南永感互联网科技有限公司
高科技互联网
互联网和科技技术
互联网科技有限公司图片
金融科技创新监管互联网金融
互联网科技论文
深圳齐家互联网科技
碳银互联网科技有限公司
互联网科技大会案例
富国互联网科技创新基金
以后互联网后是啥科技
科技与互联网哪个更好
全球顶尖互联网科技公司
互联网科技公司有风险吗
搜狐科技互联网
互联网科技创新的路径
科技大学互联网
长沙渺峰互联网科技有限公司
三亚科技创新互联网基地
互联网巨头反垄断金融科技
互联网金融 科技
新浪科技互联网
小米互联网科技园设置
南山科技园互联网公司有哪些
互联网经济与金融科技
燊美集互联网科技有限公司
福州德业互联网科技
吉林省码上互联网科技电话
保山互联网科技靠谱吗