Home » Other » Training & Certification » How duplicates can be removed from an array in oracle (Oracle 9.2.0.3)
How duplicates can be removed from an array in oracle [message #361108] Tue, 25 November 2008 01:29 Go to next message
avik2009
Messages: 61
Registered: November 2008
Member

How duplicates can be removed from an array in oracle?
Re: How duplicates can be removed from an array in oracle [message #361113 is a reply to message #361108] Tue, 25 November 2008 01:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Array? Which kind of array?

Regards
Michel
Re: How duplicates can be removed from an array in oracle [message #361128 is a reply to message #361113] Tue, 25 November 2008 02:00 Go to previous messageGo to next message
avik2009
Messages: 61
Registered: November 2008
Member
Array type
Re: How duplicates can be removed from an array in oracle [message #361146 is a reply to message #361128] Tue, 25 November 2008 03:09 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> create or replace type myarray is table of number
  2  /

Type created.

SQL> declare
  2    v1 myarray;
  3    v2 myarray;
  4  begin
  5    select round(dbms_random.value(1,3)) bulk collect into v1 
  6    from dual connect by level <= 10;
  7    for i in 1..v1.count loop 
  8      dbms_output.put_line('i='||i||' v='||v1(i));
  9    end loop;
 10    dbms_output.put_line('-----------------');
 11    select distinct * bulk collect into v2 from table(v1);
 12    for i in 1..v2.count loop 
 13      dbms_output.put_line('i='||i||' v='||v2(i));
 14    end loop;
 15  end;
 16  /
i=1 v=1
i=2 v=2
i=3 v=2
i=4 v=2
i=5 v=2
i=6 v=2
i=7 v=1
i=8 v=1
i=9 v=2
i=10 v=3
-----------------
i=1 v=1
i=2 v=2
i=3 v=3

PL/SQL procedure successfully completed.

Regards
Michel
Previous Topic: All about Oracle Database 11g, 10g, 9i
Next Topic: Procedure vs Function
Goto Forum:
  


Current Time: Sat Dec 03 12:09:27 CST 2016

Total time taken to generate the page: 0.07478 seconds