sql - 如何将 Oracle 集合数据插入表的 CLOB 列
问题描述
我在集合变量中有记录。O 想将所有记录插入到表的 CLOB 列中。
set serveroutput on;
declare
type ROW_DATA is table of varchar2(256) ;
ROW_D ROW_DATA;
begin
with DIFF_TAB_DATA as
(
select SOME_COLUMN from SOME_TABLE1
union all
select SOME_COLUMN from SOME_TABLE2
union all
select SOME_COLUMN from SOME_TABLE3
union all
select SOME_COLUMN from SOME_TABLE4
union all
select SOME_COLUMN from SOME_TABLE5
)
select SOME_COLUMN bulk collect into ROW_D from DIFF_TAB_DATA;
insert into CLOB_TAB values(ROW_D);
end;
但是我得到了本地集合变量不能在插入语句中使用的错误。
解决方案
是的,这是一个不匹配。本地集合类型不能替换为当前值的数据类型,它们是完全不相关的。而是将集合与索引集一起调用以提取存储在其中的值。为了执行此操作,只需更换
INSERT INTO clob_tab VALUES(row_d);
和
FORALL indx IN 1 .. row_d.COUNT
INSERT INTO clob_tab VALUES(row_d(indx));
推荐阅读
- angular - ngModel 在将其作为数组获取时无法在用户的输入中工作
- quarkus - 在 Mac 上安装/运行 GraalVM 的问题
- java - 如何在安卓应用中切换黑白 admob 和 facebook 广告
- javascript - 如何修复这个 php 致命错误致命错误:未捕获错误:调用未定义函数 nm_blog_get_ajax_content()?
- reactjs - 带有 act() 错误的 React Hooks 组件的 Jest 单元测试
- mongodb - 按 ObjectId 数组对文档进行分组
- reactjs - 库 React Material UI 排版中的变体与组件有什么区别
- c# - “Between”不起作用,我的代码中的错误在哪里?
- php - 比较两个数组并在php中返回结果
- python - DockerFile:容器化 python 不允许执行进一步的命令