0

I Faced this error in a client while this procedure was executted:

    create or replace procedure remove_indice (p_tabela in varchar2, p_indice in varchar2) is
        v_qtde integer;
    begin

        select count(*) into v_qtde from user_indexes where index_name = upper(p_indice);

        if v_qtde = 0 then 
            begin
                dbms_output.put_line('indice ' || p_indice || ' nao removido (nao existe).'); 
            end;
            else
            begin   
                execute immediate('drop index ' || p_indice);
                dbms_output.put_line('indice ' || p_indice || ' removido com sucesso.'); 
            end;
        end if;
    exception
        when others then
            dbms_output.put_line('nao foi possivel remover o indice ' || p_indice);
            dbms_output.put_line('erro: ' || sqlerrm);
            raise;
    end;

S1000 6502 {[Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at "SITEF.REMOVE_INDICE", line 21 ORA-06512: at line 1

{call remove_indice ('conc_ticket_ll', 'conc_ticket_ll_indx1')}

Then I changed the procedure to this, because the error appears to happen in "raise":

    create or replace procedure remove_indice (p_tabela in varchar2, p_indice in varchar2) is
        v_qtde integer;
    begin

        select count(*) into v_qtde from user_indexes where index_name = upper(p_indice);

        if v_qtde = 0 then 
            begin
                dbms_output.put_line('indice ' || p_indice || ' nao removido (nao existe).'); 
            end;
            else
            begin   
                execute immediate('drop index ' || p_indice);
                dbms_output.put_line('indice ' || p_indice || ' removido com sucesso.'); 
            end;
        end if;
    end;

Then I got this:

S1000 6502 {[Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 1 ORA-06512: at "SITEF.REMOVE_INDICE", line 13 ORA-06512: at line 1

In my environment the error doesn't occurs. The procedure simple checks if an index exists, and remove it if exists. If not exists, don't stop the application with error (it's an installer).

Some notes: 1- The connection is made through ODBC; 2- In the client environment, the error doesn't occurs through SqlPlus:

    set serveroutput on;
    begin
        remove_indice ('conc_ticket_ll', 'conc_ticket_ll_indx1');
    end;

indice conc_ticket_ll_indx1 removido com sucesso.

PL/SQL procedure successfully completed.

3- Oracle ODBC driver in the same version of mine, same OS.

  • 2
    Possible duplicate of [ORA-06502: PL/SQL: numeric or value error: character string buffer too small](https://stackoverflow.com/questions/18731560/ora-06502-pl-sql-numeric-or-value-error-character-string-buffer-too-small) – Jonathon Reinhart Mar 20 '18 at 14:01
  • 1
    @JonathonReinhart: I disagree - this is not a dup of the other problem. There are no variables being defined here, as best as I can see, so I don't see how this error is occurring. – Bob Jarvis - Слава Україні Mar 20 '18 at 14:53
  • I would suggest to take it step by step. 1. create an index and then try to remove it using the "execute immediate" command. 2. If it works fine, try to replace it with a call of the procedure "remove_index". If not, they to check the name of the index if it fits the constraints from user_indexes table on column index_name... – mikcutu Mar 20 '18 at 15:27
  • not sure if it will help but the documentation for execute immediate ( https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems017.htm) does not have a bracket after the immediate. This would make your command execute immediate 'drop index ' || p_indice It is possible that the system you are executing from is interpreting this slightly differently. – Shaun Peterson Mar 20 '18 at 23:25
  • Executed using ODBC, no issues, both of your versions. What is your client, the one using ODBC and the one that understands sqlplus commands (serveroutput)? – access_granted Mar 21 '18 at 01:46

0 Answers0