当前位置:网站首页>Oracle 存储过程之遍历
Oracle 存储过程之遍历
2022-07-07 18:03:00 【江湖小蟹】
以下内容主要介绍Oracle存储过程中,如何使用for循环遍历拼接好的SQL语句,并执行。
- 循环的写法
注:为了语句简洁,下面代码块中的“SQL语句”的SQL会在下面展示。
FOR ARR IN (SQL语句) LOOP
-- 控制台打印(正式运行时,建议删除或注释)
DBMS_OUTPUT.PUT_LINE(ARR.SS);
-- 执行sql
EXECUTE IMMEDIATE ARR.SS;
END LOOP;
不要纠结下面的语句,看意就好。主要是想表达最终执行的SQL是怎么来的。(拼接sql语句结尾不能加分号,否则执行sql会出错)
SELECT 'UPDATE SCHOOL_ROll SET ROLL = '|| S.ROLL || 'WHERE ID = ' || S.ID FROM STUDNETS AS S
- 完整存储过程语句
CREATE
OR REPLACE PROCEDURE "SP_OA_SL" AS BEGIN
-- 遍历SQL执行结果
FOR ARR IN ( SQL语句 ) LOOP
-- 控制台打印(正式运行时,建议删除或注释)
DBMS_OUTPUT.PUT_LINE ( ARR.SS );
-- 执行sql
EXECUTE IMMEDIATE ARR.SS;
END LOOP;
END;
边栏推荐
- Opencv学习笔记 高动态范围 (HDR) 成像
- Simulate the implementation of string class
- Flink并行度和Slot详解
- Force buckle 599 Minimum index sum of two lists
- Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
- R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
- Boot 和 Cloud 的版本选型
- 使用高斯Redis实现二级索引
- 力扣 2319. 判断矩阵是否是一个 X 矩阵
- 力扣 1037.有效的回旋镖
猜你喜欢
随机推荐
力扣 1037.有效的回旋镖
IP tools
torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
Force buckle 2315 Statistical asterisk
【STL】vector
时间工具类
整型int的拼接和拆分
Cloud 组件发展升级
JVM GC垃圾回收简述
openEuler 资源利用率提升之道 01:概论
【哲思与实战】程序设计之道
Compiler optimization (4): inductive variables
CUDA versions are inconsistent, and errors are reported when compiling apex
毕业季|遗憾而又幸运的毕业季
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
R language ggplot2 visualization: use the ggecdf function of ggpubr package to visualize the grouping experience cumulative density distribution function curve, and the linetype parameter to specify t
LeetCode_ 7_ five
pom.xml 配置文件标签作用简述


![最多可以参加的会议数目[贪心 + 优先队列]](/img/f3/e8e939e0393efc404cc159d7d33364.png)





