ORA-06502: PL/SQL: numeric or value error

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Responder
GAraujo
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Mensagens: 7
Registrado em: Seg, 13 Jul 2015 4:06 pm

Pessoal, boa tarde!

Estou precisando de uma ajuda, estou tendo um problema conforme o nome do tópico:
ORA-06502: PL/SQL: numeric or value error, e consequentemente ele gera o erro ORA-06512.

Segue código

Selecionar tudo

procedure Output(pname varchar2 default null,pdest varchar2 default null) is
   myName word := pname;
   myDest word := pdest;
   v_doc blob;      -- finally complete document
   v_blob blob;
   v_clob clob;
   v_in pls_integer;
   v_out pls_integer;
   v_lang pls_integer;
   v_warning pls_integer;
   v_len pls_integer;
begin
   dbms_lob.createtemporary(v_blob, false, dbms_lob.session);
   dbms_lob.createtemporary(v_doc, false, dbms_lob.session);
  -- Output PDF to some destination
  -- Finish document if necessary
     
  if state < 3 then
    ClosePDF();
  end if; 
     
  myDest := strtoupper(myDest);
  if(myDest is null) then
    if(myName is null) then
      myName := 'doc.pdf';
      myDest := 'I';
    else
      myDest := 'D';
    end if; 
  end if; 
  
  if (myDest = 'I') then 
      -- Send as pdf to a browser
      OWA_UTIL.MIME_HEADER('application/pdf',false);
      htp.print('Content-Length: ' || getPDFDocLength());
      htp.print('Content-disposition: inline; filename="' || myName || '"');
      owa_util.http_header_close;

   -- restitution du contenu...
      v_len := 1;
      
      for i in pdfDoc.first..pdfDoc.last loop
         v_clob := to_clob(pdfDoc(i));
         if v_clob is not null then
            v_in := 1;
            v_out := 1;
            v_lang := 0;
            v_warning := 0;
            v_len := dbms_lob.getlength(v_clob); 
            dbms_lob.convertToBlob(v_blob, v_clob, v_len,
                                     v_in,  v_out,
                                      dbms_lob.default_csid, v_lang, v_warning);
            dbms_lob.append(v_doc, dbms_lob.substr(v_blob, v_len));   
         end if;
      end loop;
      wpg_docload.download_file(v_doc);
       
  elsif (myDest = 'D') then
      
   -- Download file
   if(not empty(owa_util.get_cgi_env('HTTP_USER_AGENT')) and instr(owa_util.get_cgi_env('HTTP_USER_AGENT'),'MSIE') > 0) then
    OWA_UTIL.MIME_HEADER('application/force-download',false);
   else
    OWA_UTIL.MIME_HEADER('application/octet-stream',false);
   end if; 
   htp.print('Content-Length: ' || getPDFDocLength());
   htp.print('Content-disposition: attachment; filename="' || myName || '"');
   owa_util.http_header_close;

   -- restitution du contenu...
    for i in pdfDoc.first..pdfDoc.last loop
      htp.prn(pdfDoc(i));
    end loop;
        
  elsif (myDest = 'S') then 
     
      --OWA_UTIL.MIME_HEADER('application/pdf');
   OWA_UTIL.MIME_HEADER('text/html');
   -- Return as a string
   for i in pdfDoc.first..pdfDoc.last loop
     htp.prn(replace(replace(replace(pdfDoc(i),'<', '<'),'>','>'),chr(10),'<br/>'));
   end loop;
  else
   Error('Incorrect output destination: ' || myDest);
  end if;
exception 
   when others then
      error('Output : '||sqlerrm);
end Output;
Procurei diversas maneiras de resolver, porém não obtive êxito.

Aguardo uma solução.

Att,
GAraujo.
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Você não consegue ver o número da linha que deu erro?
Normalmente isso ocorre em um campo que está esperando número, e você coloca texto.

Se não tem como descobrir o número da linha, nem debugar, coloca umas variáveis indicando a posição.
Exemplo:

Selecionar tudo

V_local:=1;
...codigo.
v_local:=2;
...mais codigo
v_local:=3;
E coloca um exception pra mostrar esse número. Pelo menos assim você sabe onde está o erro. Senão fica difícil dizer.
Responder
  • Informação