Oracle - ORA-01722: invalid number

Asked

Viewed 9,613 times

0

Can you help me with this error? It usually gives invalid number when I don’t quote simply. I tried to convert to number (although column is varchar2), but error persists

DECLARE

  TYPE cVetor IS VARRAY(4) OF NUMBER(30);

  V_DATA DATE;

  carnes cVetor := cVetor('2023621240781',' 2012321237746', '20192321236243', '2019612128378');

    BEGIN

        V_DATA := TO_DATE('19/01/2019 03:00:00', 'DD/MM/YYYY HH24:MI:SS');

        FOR i in 1..carnes.count LOOP

          BEGIN


          UPDATE OW.CARNE CAR
             SET CAR.DT_EMISSAO       = V_DATA,
                 CAR.DT_GERACAO       = V_DATA,
                 CAR.DT_BAIXA         = V_DATA,
                 CAR.DT_BAIXA_SISTEMA = V_DATA
           WHERE CAR.TXT_NOSSO_NUMERO = carnes(i); --VARCHAR2(15)

          UPDATE OW.COBRANCA COB
             SET COB.DT_EMISSAO       = V_DATA,
                 COB.DT_GERACAO       = V_DATA,
                 COB.DT_BAIXA         = V_DATA,
                 COB.DT_BAIXA_SISTEMA = V_DATA
           WHERE COB.TXT_NOSSO_NUMERO = carnes(i); --VARCHAR(15)
          COMMIT;

          DBMS_OUTPUT.PUT_LINE('Carnê' || carnes(i) || 'atualizado');

        EXCEPTION
          WHEN OTHERS THEN
            ROLLBACK;
            DBMS_OUTPUT.PUT_LINE('ERRO CARNE ' || carnes(i) || sqlerrm);
       END;
       END LOOP;
    END;

inserir a descrição da imagem aqui

1 answer

4


COB.TXT_NOSSO_NUMERO = to_char(carnes(i));

Try it this way

Browser other questions tagged

You are not signed in. Login or sign up in order to post.