【发布时间】:2018-11-04 23:55:39
【问题描述】:
在我们的 Oracle 11g 数据库中,我有一个自定义数据类型:
num_list
create or replace type
num_list
as
table of varchar2(25);
然后我创建了一个使用此数据类型的表:
create table num_list_table(
id number(*,0)
,numbers num_list
) nested table numbers store as numbers_tab
;
然后我插入了以下行:
insert into num_list_table values (1, num_list('123', 456'));
我现在有 1 行。我试图弄清楚如何在第 1 行的 num_list 中插入更多值,同时保留任何现有值,而不必手动输入这些现有值;这是一个更大的任务的一个小例子,需要在保留 val 的同时进行大量更新。
我很接近这个:
update
num_list_table
set numbers = (select num_list(numbers) from (
select listagg(numbers, ',') within group (order by numbers) numbers
from (select t.column_value numbers
from
num_list_table nlt,
table(nlt.numbers) t
where
st.id = 1
union
select '789'
from dual)))
where id = 1;
但是,这些结果是一个条目:
num_list('123,456,789')
我需要它们是 num_list 中的多个条目:
num_list('123', '456', '789')
我们将不胜感激。
【问题讨论】:
标签: sql oracle oracle11g custom-type