FOR loop_counter IN [REVERSE] lowest_number..highest_number LOOP {.statements.} END LOOP; You would use a FOR Loop when you want to execute the loop body a fixed number of times. 译:当你需循环体执行一定的次数的时候,就可以使用FOR Loop。 Let's take a look at an example. FOR Lcntr ...
declarel_sqlvarchar2(123);--variable that contains a queryl_c sys_refcursor;--cursor variable(weak cursor).l_res your_table%rowtype;--variable containing fetching databeginl_sql :='select * from your_table';--Open the cursor and fetching data explicitly--in the LOOP.openl_cforl_sql; ...
PL-SQL also has FOR LOOP facility. Basically for loop in PL_SQL are of two types. First is Numerical for loop and the second one is Curser for a loop. SO in this post, we will focus mainly on Numerical for a loop. So, FOR LOOP enable us to iterate any statement or statements in...
In the example below we have used a the for loop to print numbers from 1 to 10.set serveroutput on; DECLARE i number(2); BEGIN FOR i IN 1..10 LOOP dbms_output.put_line(i); END LOOP; END; Copy1 2 3 4 5 6 7 8 9 10 PL/SQL procedure successfully completed. ...
如果结果为FALSE,则循环主体不执行,并且控 制流程跳转到for循环之后的下一个语句。 执行for循环的主体后,增加或减少计数器变量的值。 现在再次评估条件。 如果计算为TRUE,则执行循环并且该过程重复(循环体,然后增量步,然后再次调节)。 条件变为FALSE后,FORLOOP终止。 以下是PL/SQL for循环的一些特殊特性 - 循环...
1. PL/SQL中的流控制概述 2. IF语句的基础用法 3. 复杂条件判断:IF...ELSIF...ELSE结构 4. 条件组合判断 5. 循环语句:LOOP结构 6. 条件判断与循环结合:实际应用示例 1. PL/SQL中的流控制概述 PL/SQL提供了丰富的流控制语句,用来对程序的执行流程进行控制。流控制语句可以分为两类:条件判断语句和循环语...
A) Simple PL/SQL FOR LOOP example In this example, the loopindexisl_counter,lower_boundis one, andupper_boundis five. The loop shows a list of integers from 1 to 5. BEGINFORl_counterIN1..5LOOPDBMS_OUTPUT.PUT_LINE( l_counter );ENDLOOP;END;Code language:SQL (Structured Query Language...
1) PL/SQL cursor FOR LOOP example The following example declares an explicit cursor and uses it in the cursor FOR LOOP statement. DECLARE CURSOR c_product IS SELECT product_name, list_price FROM products ORDER BY list_price DESC; BEGIN FOR r_product IN c_product LOOP dbms_output.put_lin...
In Oracle, the FOR LOOP allows you to execute code repeatedly for a fixed number of times. Syntax The syntax for the FOR Loop in Oracle/PLSQL is: FORloop_counterIN [REVERSE]lowest_number..highest_numberLOOP {...statements...} END LOOP; ...
在PL/SQL中可以使用LOOP语句对数据进行循环处理,利用该语句可以循环执行指定的语句序列。常用的LOOP循环语句包含3种形式:基本的LOOP、WHILE...LOOP和FOR...LOOP。 LOOP语句的基本语法结构如下: [<>] LOOP statement... END LOOP [label_name] 【语法说明】 ...