varchar字符串瓜分
varchar字符串分割
刚写的,备份下
declare str varchar2(100) := 'ids=121|age=1356|password=gaowei'; temp varchar2(200) := ''; s_current varchar2(200) := ''; -- 当前遍历的字符串 start_index int:=1; -- 开始索引 end_index int := 0; -- 截取多少个字符串 begin -- 分隔str for i in 1..length(str) loop end_index := end_index + 1; -- 循环一次就加一次,比如第一次循环那么就截取1个字符串 s_current := substr(str,i,1); -- 拿到当前字符串 'i' if (s_current = '|') or i = length(str) then --dbms_output.put_line(start_index || '==' || end_index); temp := substr(str,start_index,end_index); start_index := i+1; end_index := 0; if i <> length(str) then dbms_output.put_line(substr(temp,1,length(temp)-1)); -- dbms_output.put_line(temp); else dbms_output.put_line(temp); end if; end if; end loop; end;