2014-12-05 59 views

回答

2

聲明您的數組是這樣的:

"your array" apex_application_global.vc_arr2; 

    "your array" := APEX_UTIL.STRING_TO_TABLE("your string",' '); 

    FOR i IN 1.. "your array".COUNT LOOP 

    "Your string" := "Your string"|| "your array"(i); 

    END LOOP; 

和你有它

+0

謝謝這個工作。 – SHEePYTaGGeRNeP 2014-12-05 10:45:24

0

這是不使用任何包,只是甲骨文的SQL最終的和通用的解決方案。見一個全功能的解決方案(包括流水線功能)在這裏:http://www.armbruster-it.org/index.php/12-it/pl-sql/20-string-tokenizer-with-oracle-pl-sql

declare 
    cursor c_tokenizer(ci_string in varchar2, ci_delimiter in varchar2) is 
    SELECT regexp_substr(str, '[^' || ci_delimiter || ']+', 1, LEVEL) AS splitted_element, 
      LEVEL AS element_no 
     FROM (SELECT rownum AS id, ci_string str FROM dual) 
    CONNECT BY instr(str, ci_delimiter, 1, LEVEL - 1) > 0 
      AND id = PRIOR id 
      AND PRIOR dbms_random.value IS NOT null; 

    l_string varchar2(100) := 'Hello World, I like PL/SQL'; 
    l_delimiter varchar2(1) := ' '; 
begin 
    -- extract each word of the string above (delimited by blank) 
    for c1 in c_tokenizer(l_string, l_delimiter) loop 
    dbms_output.put_line(c1.splitted_element); 
    end loop; 
end; 

結果是:

Hello 
World, 
I 
like 
PL/SQL