当前位置:网站首页>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;
边栏推荐
- vulnhub之school 1
- [auto.js] automatic script
- How to cooperate among multiple threads
- Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
- Opencv学习笔记 高动态范围 (HDR) 成像
- Compiler optimization (4): inductive variables
- 关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
- Ways to improve the utilization of openeuler resources 01: Introduction
- JVM GC garbage collection brief
- Throughput
猜你喜欢
8 CAS
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
CSDN syntax description
openEuler 有奖捉虫活动,来参与一下?
整型int的拼接和拆分
9 atomic operation class 18 Rohan enhancement
Nunjuks template engine
Ways to improve the utilization of openeuler resources 01: Introduction
华南X99平台打鸡血教程
微信公众号OAuth2.0授权登录并显示用户信息
随机推荐
使用高斯Redis实现二级索引
Some important knowledge of MySQL
R language dplyr package select function, group_ The by function, filter function and do function obtain the third largest value of a specific numerical data column in a specified level in a specified
R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
力扣 2315.统计星号
831. KMP string
CUDA versions are inconsistent, and errors are reported when compiling apex
Compiler optimization (4): inductive variables
时间工具类
vulnhub之school 1
Make this crmeb single merchant wechat mall system popular, so easy to use!
Time tools
【哲思与实战】程序设计之道
华南X99平台打鸡血教程
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
编译器优化那些事儿(4):归纳变量
力扣 1037.有效的回旋镖
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
R language ggplot2 visualization: use the ggqqplot function of ggpubr package to visualize the QQ graph (Quantitative quantitative plot)