oracle怎么拆字符串 oracle将字符串按指定符号拆开

ORACLE 怎么拆分字符串拆分sql后:
select
substr('Hello World',0,instr('Hello World','o')) as 首,
substr('Hello World',instr('Hello World','o') 1) as 尾
from dual;
有什么规定吗?
“ABCDEFGH”或是“A , B,C , D,E,F,G,H"
按符号拆分?按位置拆分?
substr()函数:截取a-b之间的或a。如:substr('Hello World',0,5)截取1-5或
substr('Hello World',0,instr('Hello World','o'))截取1-"o"的位置
1.如果是","等符号:
select substr('Hello World',0,instr('Hello World','o'))from dual;
select substr('Hello World',instr('Hello World','o') 1)from dual;

select substr('Hello World',instr('Hello World','o') 1,length('Hello World'))from dual;
Oracle按指定字符拆分字符串-split函数create or replace type strArray as table of varchar2(4020)
--此方法只能使用英文半角逗号(,)
create or replace function f_split(instr IN VARCHAR2) return strArray
as
l_tablen BINARY_INTEGER;
l_tabDBMS_UTILITY.uncl_array;
l_ret strArray:=strArray();
BEGIN
DBMS_UTILITY.comma_to_table(instr, l_tablen, l_tab);
FOR i IN 1 .. l_tablen LOOP
l_ret.EXTEND(1);
l_ret(i):=l_tab(i);
END LOOP;
return l_ret;
END;
select t.column_value as value from table(f_split('a,b,付')) t;
create or replace type strArray as table of varchar2(4020)
CREATE OR REPLACE FUNCTION f_split(p_strIN VARCHAR2, p_delimiter IN VARCHAR2)
RETURN strArray IS
TYPE ret_cur IS REF CURSOR;
ret_cur1 ret_cur;
g_str strarray:=strarray();
l_sql varchar2(500):='';
BEGIN
l_sql :='SELECT REGEXP_SUBSTR ('''||p_str||''',''[^'||p_delimiter||'] '',1,LEVEL) as valuesa
FROM DUAL
CONNECT BY REGEXP_SUBSTR ('''||p_str||''',''[^'||p_delimiter||'] '',1,LEVEL) IS NOT NULL';
OPEN ret_cur1 FOR l_sql ;
FETCH ret_cur1 BULK COLLECT INTO g_str;
CLOSE ret_cur1;
RETURN g_str;
END f_split;
【oracle怎么拆字符串 oracle将字符串按指定符号拆开】 select * from table(f_split('abc$d$e$','$') );
oracle根据某个字符拆分字符串 /*
*根据某个字符拆分字符串
*/
CREATE OR REPLACE TYPE str_split IS TABLE OF VARCHAR2 (4000);
CREATE OR REPLACE FUNCTION splitstr(p_string IN VARCHAR2, p_delimiter IN VARCHAR2)
RETURN str_split
PIPELINED
AS
v_lengthNUMBER := LENGTH(p_string);
v_startNUMBER := 1;
v_indexNUMBER;
BEGIN
WHILE(v_start = v_length)
LOOP
v_index := INSTR(p_string, p_delimiter, v_start);
/ 示范 /
SELECT * from table(splitstr('Hello,Cnblogs!',','));
oracle怎么拆字符串的介绍就聊到这里吧 , 感谢你花时间阅读本站内容 , 更多关于oracle将字符串按指定符号拆开、oracle怎么拆字符串的信息别忘了在本站进行查找喔 。

    推荐阅读