- PROCEDURE Str_To_Arr(p_Source_Str IN VARCHAR2,
- p_Split_Str IN VARCHAR2,
- Errbuf OUT VARCHAR2,
- Retcode OUT VARCHAR2,
- p_Dens_Array OUT Type_Tab_Arr) IS
- v_Source_Str VARCHAR2(1000);
- v_Split_Str VARCHAR2(8);
- v_Count NUMBER; ----分割的个数
- v_Split_Local NUMBER; ----分割符出现的位置
- v_Pos_Local NUMBER; ----分割起始位置
- v_Tab_Arr Xxt_Gl_Load_Vat_Pkg.Type_Tab_Arr;
- BEGIN
- Retcode := 0;
- v_Pos_Local := 1;
- v_Count := 1;
- v_Source_Str := p_Source_Str;
- v_Split_Str := p_Split_Str;
- IF Length(v_Source_Str) = 0 THEN
- Log('判断1');
- Errbuf := '要分割的字符串为空,请输入要分割的字符串!';
- Retcode := '2';
- RETURN;
- END IF;
- IF Length(v_Split_Str) = 0 THEN
- Log('判断2');
- Errbuf := '请输入要分割的界定符!';
- Retcode := '2';
- RETURN;
- END IF;
- ---取出字符串的个数
- SELECT Length(v_Source_Str) -
- Length(REPLACE(Translate(v_Source_Str, v_Split_Str, ' '),
- ' ',
- '')) / Length(v_Split_Str)
- INTO v_Count
- FROM Dual;
- FOR i IN 1 .. v_Count LOOP
- SELECT Instr(v_Source_Str, v_Split_Str, v_Pos_Local + 1, 1)
- INTO v_Split_Local
- FROM Dual;
- IF v_Split_Local = 0 THEN
- v_Tab_Arr(i) := v_Source_Str;
- dbms_output.put_line(v_tab_arr(i));
- EXIT;
- ELSE
- IF i = 1 THEN
- v_Tab_Arr(i) := Substr(v_Source_Str,
- v_Pos_Local,
- v_Split_Local - v_Pos_Local);
- v_Pos_Local := v_Split_Local;
- Dbms_Output.Put_Line(v_Tab_Arr(i));
- ELSE
- v_Tab_Arr(i) := Substr(v_Source_Str,
- v_Pos_Local + Length(v_Split_Str),
- v_Split_Local -
- (v_Pos_Local + Length(v_Split_Str)));
- v_Pos_Local := v_Split_Local;
- --Dbms_Output.Put_Line(v_Tab_Arr(i));
- END IF;
- END IF;
- END LOOP;
- p_Dens_Array := v_Tab_Arr;
- END Str_To_Arr;