Oracle/PLSQL CURSOR FOR Loop

Posted 有没有成功

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle/PLSQL CURSOR FOR Loop相关的知识,希望对你有一定的参考价值。

 
Oracle/PLSQL: CURSOR FOR Loop
 
The syntax for the CURSOR FOR Loop is:
FOR record_index in cursor_name
LOOP
      {.statements.}
END LOOP;
You would use a CURSOR FOR Loop when you want to fetch and process every record in a cursor. The CURSOR FOR Loop will terminate when all of the records in the cursor have been fetched.
译:当你每次想通过cursor来对每条记录进行取及操作时,就可以使用CURSOR FOR Loop。当cursor中所有的记录都取后,CURSOR FOR Loop就会终止。
Here is an example of a function that uses a CURSOR FOR Loop:
CREATE OR REPLACE Function TotalIncome
    ( name_in IN varchar2 )
    RETURN varchar2
IS
    total_val number(6);

    cursor c1 is
      select monthly_income
      from employees
      where name = name_in;

BEGIN
total_val := 0;
FOR employee_rec in c1
LOOP
    total_val := total_val + employee_rec.monthly_income;
END LOOP;

RETURN total_val;
END;
In this example, we‘ve created a cursor called c1. The CURSOR FOR Loop will terminate after all records have been fetched from the cursor c1.
译:在这个示例中,我们建立了一个名为c1的cursor。当所有c1中的记录都取后,CURSOR FOR Loop就会终止。
 

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow




















以上是关于Oracle/PLSQL CURSOR FOR Loop的主要内容,如果未能解决你的问题,请参考以下文章

『ORACLE』 PLSQL游标的使用(11g)

Oracle PLSQL BULK 收集和 For 循环

Oracle PLSQL 函数抛出 PL/SQL: numeric or value error: string buffer too small , for return large data

oracle PLSQL 查询语句select t.*, t.rowid from PU.YK t

不装oracle plsql怎么用

急! 换电脑之前PLSQL可以正常登陆 换电脑后PLSQL和 ORACLE 都没重装 现在运行plsql登录错误,有空白提示框