Why multiset union is not working when I'm trying to concatenate a null with some number in plsql?

时间:2018-03-25 21:01:29

标签: sql oracle user-defined-types

So i have two nested tables and i want to make a new one with the elements from both of them but the first nested table have an null value and the second one an number and i want the result to be the number in the second one but he print the null value. It is possible to make a union between a null and an number with multiset union ?

1 个答案:

答案 0 :(得分:1)

要回答你的问题,是的,"可以使用multiset union" 在null和数字之间建立联合。但你最终得到的是嵌套表中的两个条目:

SQL> update test 
  2  set marks = numberlist(null) multiset union all numberlist(42) 
  3  where id_std = 1 
  4 /
SQL> select id_std 
  2       , t2.column_value as mark 
  3  from test t1 
  4     , table(t1.marks) t2 
  5  /

ID_STD  MARK
------  ----
     1
     1    42

SQL>

我怀疑这种影响实际上是你所抱怨的。但是,空标记仍然是有效条目。如果要覆盖它,则需要提供不同的逻辑。