Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to assign the value of one collection to another?

msJun 27 2017 — edited Jun 28 2017

Hello Everyone,

How can i assign the value of one collection to another. I have created 2 varrays and trying to assign the value of 1 varray to another.

Can you kindly suggest as to why i am not getting the values of varray v2 in the output below? Also is it possible to assign the entire contents of v1 i.e

1 to 5 to v2 at one time (without using for loop as it assigns one at a time). Thanks.

This is the sample anonymous blobk i have awritten.

set serveroutput on

declare

type t1 is varray(5) of number;

v1 t1:=t1();

type t2 is varray(5) of number;

v2 t2:=t2();

begin

for i in 1..5

loop

v1.extend;

v2.extend;

v1(v1.last):=i;

dbms_output.put_line('the values of v1 is '||v1(i));

v1(i):=v2(i);

dbms_output.put_line('the values of v2 is '||v2(i));

end loop;

end;

The output i get is :

PL/SQL procedure successfully completed.

the values of v1 is 1

the values of v2 is

the values of v1 is 2

the values of v2 is

the values of v1 is 3

the values of v2 is

the values of v1 is 4

the values of v2 is

the values of v1 is 5

the values of v2 is

Thanks

Gautam

This post has been answered by mathguy on Jun 28 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 26 2017
Added on Jun 27 2017
4 comments
1,231 views