ORACLE 学习资料第五章
游标:
隐式游标:%FOUND, %NOTFOUND ,%ROWCOUNT
1.%FOUND 用法,只有在 DML 语句阻碍一行或者多行时,%FOUND
属性才返回 TRUE。下列示例演示了 %FOUND 的用法:
begin
update employees2 set first_name = first_name ||' t' where e
mployee_id = 2;
if SQL%found then
dbms_output.put_line('数据差不多更新');
-- dbms_output.put_line('rowCount = '||mrowcount);
else
dbms_output.put_line('数据没有找到');
end if;
end;
/
以下代码演示了创建了一个游标,返回 employees2 表中 salary 大于 30
0000 的记录,注意 type 的使用:
declare
csalary employees2.salary%type;
cursor emp2_cursor is select salary from employees2 where
salary >300000;
begin
open emp2_cursor ;
loop
fetch emp2_cursor into csalary;
exit when emp2_cursor%notfound;
dbms_output.put_line('csalary = '||csalary);
end loop;
评论0
最新资源