tags:

views:

19

answers:

1

Q.accrept any string having any no.of comma in the string and display all the words seperated by commas in seperate lines?

example: delhi,mumbai,pune,puri

i want output like this

outpt: delhi mumbai pune puri

+3  A: 

from here

DECLARE
  lv_Str_List       VARCHAR2(1000) := 'delhi,mumbai,pune,puri';
  lb_cnt             BINARY_INTEGER;
  la_Tab_Str       DBMS_UTILITY.UNCL_ARRAY;
BEGIN
  -- parse the string into comma separated table
  DBMS_UTILITY.COMMA_TO_TABLE(lv_Str_List, lb_cnt, la_Tab_Str);
  FOR i IN 1 .. la_Tab_Str.COUNT LOOP
    -- display substring
    DBMS_OUTPUT.PUT_LINE(TRIM(la_Tab_Str(i)));
  END LOOP;
END;
/
Paul Creasey