当前位置:网站首页>Oracle 存儲過程之遍曆
Oracle 存儲過程之遍曆
2022-07-07 20:08: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;
边栏推荐
- Visual Studio 插件之CodeMaid自动整理代码
- mysql 的一些重要知识
- 关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
- Force buckle 912 Sort array
- Force buckle 1961 Check whether the string is an array prefix
- 第二十章 使用工作队列管理器(三)
- Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
- Graduation season | regretful and lucky graduation season
- 力扣599. 两个列表的最小索引总和
- YoloV6:YoloV6+Win10---训练自己得数据集
猜你喜欢

Cloud component development and upgrading

9 atomic operation class 18 Rohan enhancement

MRS离线数据分析:通过Flink作业处理OBS数据

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. 数组中出现次数超过一半的数字

ASP. Net kindergarten chain management system source code

mysql 的一些重要知识

Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!

编译器优化那些事儿(4):归纳变量

Data island is the first danger encountered by enterprises in their digital transformation
随机推荐
Training IX basic configuration of network services
JVM GC垃圾回收简述
PMP practice once a day | don't get lost in the exam -7.7
The boundary of Bi: what is bi not suitable for? Master data, Martech? How to expand?
[auto.js] automatic script
pom.xml 配置文件标签作用简述
Chapter 9 Yunji datacanvas company won the highest honor of the "fifth digital finance innovation competition"!
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Throughput
sql 常用优化
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
使用高斯Redis实现二级索引
线性基
mock.js从对象数组中任选数据返回一个数组
YoloV6:YoloV6+Win10---训练自己得数据集
编译器优化那些事儿(4):归纳变量
torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
Openeuler prize catching activities, to participate in?
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
干货分享|DevExpress v22.1原版帮助文档下载集合