手表网站,建设的访问网站需要密码,阿里云中英文网站建设,长春建设招标网oralce plsql编程的游标游标分类1显示游标2隐式游标隐式游标#xff0c;oracle自动管理#xff0c;不用声明#xff0c;打开和关闭#xff0c;ORACLE自动处理#xff0c;使用隐式游标%FOUND时#xff0c;需要加上 SQL%FOUND显示游标#xff0c;需要自己声明#xff0c;…oralce plsql编程的游标游标分类1显示游标2隐式游标隐式游标oracle自动管理不用声明打开和关闭ORACLE自动处理使用隐式游标%FOUND时需要加上 SQL%FOUND显示游标需要自己声明打开和关闭使用%ROWCOUNT属性时需要在前面加上游标名字 ,student_cur%ROWCOUNT2声明游标CURSOR cursor_name is select_statments;打开游标open cursor_name读取数据fetch cursor_name into variable_name,....variable_namen;关闭游标close cursor_name;3游标属性%ISOPEN%FOUND%NOTFOUND%ROWCOUNT4游标读取数据实例select * from students;set serveroutput on;declarev_specialty students.specialty%type;v_sname students.name%type;v_dob students.dob%type;cursor students_cur --声明游标isselect name ,dob from students where specialtyv_specialty; --游标体beginv_specialty:specialty;open students_cur; --打开游标dbms_output.put_line(学生姓名 出生日期);loopfetch students_cur into v_sname,v_dob ; --读取游标的数据exit when students_cur%NOTFOUND; --假如没有数据那么退出DBMS_OUTPUT.PUT_LINE(v_sname|| ||v_dob);end loop;close students_cur; --关闭游标end;5根据游标修改当前行数据语法 update tablename set ....where current of cursor_name;select * from teachers;declarev_title teachers.title%TYPE;CURSOR teachers_curisselect title from teachers for update;beginopen teachers_cur;loopfetch teachers_cur into v_title ;exit when teachers_cur%NOTFOUND;casewhen v_title教授 thenupdate teachers set wage1.1*wage where current of teachers_cur;when v_title高工 or v_title副教授 thenupdate teachers set wage1.1*wage where current of teachers_cur;elseupdate teachers set wagewage100 where current of teachers_cur;end case;end loop;close teachers_cur;commit;end;6根据游标删除当前数据 delete from table where current of cursor_name;select * from students;declarev_specialty students.specialty%TYPE;v_sname students.name%TYPE;CURSOR students_curisselect name,specialty from students for update;beginopen students_cur;fetch students_cur into v_sname, v_specialty ;while students_cur%FOUND loopif v_specialty 计算机 THENdelete from students where current of students_cur;end if;fetch students_cur into v_sname ,v_specialty;end loop;close students_cur;end;分享到 2011-04-12 20:39浏览 2631分类:数据库评论