1

I need to assign a collection (a nested table) of varchar2(10) elements to another collection variable the element type of which is varchar2(20). Is there any way to do this, better than building the new collection row by row in a loop?

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;
Tomasz Żuk
  • 1,288
  • 1
  • 12
  • 14

2 Answers2

0

No, you can't do that. vList10 is of a different type than vList20 so you cannot assign one to the other. You will have to loop through the contents.

Bart van der Drift
  • 1,287
  • 12
  • 30
0

this is probably mostly syntactic sugar (although Oracle: Bulk Collect performance): If your types are not local you could use a one-liner:

select column_value bulk collect into vList20 from table(vList10);
Dantel35
  • 103
  • 1
  • 5