Pular para o conteúdo
#76670
kleber
Participante

    set serveroutput on
    declare
    v_linha_original varchar2(100) := ‘3|12|4|5|7|2’;
    v_linha varchar2(100);
    v_aux number;
    v_retorno number;
    begin

    v_linha := v_linha_original;
    v_retorno := null;
    if instr(v_linha,'|') = 0 then
        v_retorno := v_linha;
        dbms_output.put_line('Retorno: '||v_retorno);
    else
        loop
            v_retorno := substr(v_linha,1,instr(v_linha,'|')-1);
            if v_retorno is null then
                v_retorno := v_linha;
                dbms_output.put_line('Retorno: '||v_retorno);
            exit;
            end if;
            dbms_output.put_line('Retorno: '||v_retorno);
    
            v_linha := substr(v_linha,instr(v_linha,'|')+1,length(v_linha));
    
    
            if length(v_linha) = 0 then
               dbms_output.put_line('Retorno: '||v_retorno);
               exit;
            end if;
    
        end loop;
    end if;
    

    end;
    /