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 merge elements from two tables (defined as local types)

lenoxMay 29 2014 — edited May 30 2014

Hi,

How can get elements from table "a" and "b" into a table "c". I could write a loop but I don't know if there is a smarter option:

DECLARE

  TYPE t IS TABLE OF NUMBER;

  a t;

  b t;

  c t;

BEGIN

  a := t(1,2,3);

  b := t(3,4,5);

  c := ...  -- c {1, 2, 3, 3, 4, 5}    

END;

I could use something like this but I would prefer define table type in a package:

CREATE OR REPLACE TYPE t AS TABLE OF NUMBER;

SELECT a MULTISET UNION b INTO c FROM dual;

Thanks in advance

This post has been answered by Moazzam on May 29 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2014
Added on May 29 2014
4 comments
1,920 views