【问题标题】:Casting between PL/SQL collections of strings of different length在不同长度的字符串的 PL/SQL 集合之间进行转换
【发布时间】:2014-09-18 12:19:01
【问题描述】:

我需要将 varchar2(10) 元素的集合(嵌套表)分配给另一个集合变量,其元素类型为 varchar2(20)。有没有比在循环中逐行构建新集合更好的方法?

declare
  type TList10 is table of varchar2(10);
  type TList20 is table of varchar2(20);
  vList10 TList10 := TList10('Test1', 'Test2');
  vList20 TList20;
begin
  -- This raises PLS-00382
  vList20 := vList10;
end;

【问题讨论】:

    标签: oracle plsql


    【解决方案1】:

    不,你不能那样做。 vList10 与 vList20 的类型不同,因此您不能将一个分配给另一个。您将不得不循环浏览内容。

    【讨论】:

      【解决方案2】:

      这可能主要是语法糖(尽管Oracle: Bulk Collect performance):如果您的类型不是本地的,您可以使用单行:

      select column_value bulk collect into vList20 from table(vList10);
      

      【讨论】:

        猜你喜欢
        • 2013-09-08
        • 1970-01-01
        • 1970-01-01
        • 2018-04-20
        • 1970-01-01
        • 2011-08-25
        • 1970-01-01
        • 2016-09-23
        • 2010-11-08
        相关资源
        最近更新 更多