Answers for "multiset operators in oracle syntax"

1

multiset operators in oracle syntax

-- MULTISET UNION
-- MULTISET UNION DISTINCT
-- MULTISET EXCEPT
-- MULTISET INTERSECT


DECLARE
    TYPE t_tab IS TABLE OF NUMBER;
    l_tab1 t_tab := t_tab(1,2,3,4,5,6);
    l_tab2 t_tab := t_tab(5,6,7,8,9,10);
BEGIN
    l_tab1 := l_tab1 MULTISET UNION l_tab2;     -- (output : 1,2,3,4,5,6,5,6,7,8,9,10)            
    -- l_tab1 := l_tab1 MULTISET UNION DISTINCT l_tab2;     (output : 1,2,3,4,5,6,7,8,9,10)  
    -- l_tab1 := l_tab1 MULTISET EXCEPT l_tab2;         (output : 1,2,3,4)  
    -- l_tab1 := l_tab1 MULTISET INTERSECT l_tab2;      (output : 5,6)  

    FOR i IN l_tab1.FIRST .. l_tab1.LAST 
    LOOP
        dbms_output.put_line(l_tab1(i));
    END LOOP;
END;
/
Posted by: Guest on March-22-2021

Browse Popular Code Answers by Language