Home » SQL & PL/SQL » SQL & PL/SQL » UTL_HTTP and wired ORA-06502: PL/SQL: numeric or value error (11g2 win32)
UTL_HTTP and wired ORA-06502: PL/SQL: numeric or value error [message #475837] Sat, 18 September 2010 02:02 Go to next message
cikic
Messages: 12
Registered: September 2006
Location: Austria
Junior Member
Hello

I have a problem using the utl_http package and I can not find the error. What is wrong with this code:

set serveroutput on

DECLARE
    req   utl_http.req;
    resp  utl_http.resp;
    value VARCHAR2(1024);
    ctx varchar2(4000);
    
    -- post/get test
    rmethod varchar2(4) := 'GET'; --'POST';
    url varchar2(1000) := 'http://finance.yahoo.com/q';
    uparameter varchar2(100) := 's';
    uvalue  varchar2(100) := 'KMP';
  BEGIN
    url := url || '?';
    /* for each parameter loop */
    if rmethod = 'POST' then
      ctx := uparameter || '=' || uvalue || '&' ;     
    else 
      url := url || uparameter || '=' || uvalue || '&';
    end if;
    /* end parameter loop */
    
    req := utl_http.begin_request(url, rmethod); 
    
    if ctx is not null then
      req := utl_http.begin_request (url, 'POST');
      utl_http.set_header(req, 'ctx-type', 'text/html');
      utl_http.set_header(req, 'ctx-length', length(ctx));
      utl_http.write_text(req, rtrim(ctx,'&'));
    end if; 
    
     UTL_HTTP.set_response_error_check( TRUE );
     UTL_HTTP.set_detailed_excp_support( TRUE );
     UTL_HTTP.set_cookie_support( TRUE );
     UTL_HTTP.set_transfer_timeout( 30 );
     UTL_HTTP.set_follow_redirect( 3 );
     UTL_HTTP.set_persistent_conn_support( TRUE );
     utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
    
     dbms_output.put_line(url);
    resp := utl_http.get_response(req);
    LOOP
      utl_http.read_line(resp, value, TRUE);
      dbms_output.put_line(value);
    END LOOP;
    utl_http.end_response(resp);
  EXCEPTION
    WHEN utl_http.end_of_body THEN
      utl_http.end_response(resp);
    when others then
      begin
        utl_http.end_response(resp);
        exception when others then null;
      end;
      dbms_output.put_line(SQLERRM);
      dbms_output.put_line(sys.utl_http.GET_DETAILED_SQLERRM());
      raise;
  END;
/


As you can see in the given result, the first part of html request is pretty fine, but then after the </head> tag it stucks. I am not able to find the promblem and would need your help - one more :-)

Error report:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 56
06502. 00000 -  "PL/SQL: numeric or value error%s"
*Cause:    
*Action:
http://finance.yahoo.com/q?s=KMP&
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>KMP: Summary for Kinder Morgan Energy Partners, - Yahoo! Finance</title>
<meta name="description" xml:space="default" content="View the basic KMP stock chart on Yahoo! Finance. Change the date range, chart type and compare Kinder Morgan Energy Partners,  against
other companies."><meta name="keywords" content="KMP, Kinder Morgan Energy Partners, , KMP stock chart, Kinder Morgan Energy Partners,  stock chart, stock chart, stocks, quotes, finance"><meta property="fb:app_id" content="118155468215844"><meta property="fb:admins" content="503762770,100001149693905"><meta property="og:type" content="company"><meta property="og:site_name" content="Yahoo! Finance"><meta property="og:title" content="Kinder Morgan Energy Partners LP"><meta property="og:image" content="http://l.yimg.com/a/p/fi/31/09/00.jpg"><meta property="og:url" content="http://finance.yahoo.com/q?s=KMP"><meta property="og:description" content="View the basic KMP stock chart on Yahoo! Finance. Change the date range, chart type and compare Kinder Morgan Energy Partners,  against
other companies.">
<link rel="stylesheet" href="http://l.yimg.com/bm/lib/fi/common/p/d/static/css/0.1.25/2.0.0/mini/yfi_quote_summary_concat.css" type="text/css">
</head>

<body id="yfi_quote_summary_page" class="intl-us">
<style type="text/css" media="screen">
            #yfi_multi_quote_page #yfi_invest_container {height:auto !important;}
            .yfi_quote_headline ul li a {margin-right: 0px;}
            #yfi_tech_ticker ul li {
    	        list-style-position:outside;
    	        margin:7px 0;
    	    }
    	    #yfi_tech_ticker li.video {
                list-style:disc outside none;
            }
            #yfi_tech_ticker .ft {
                padding:0;
            }
ORA-06502: PL/SQL: numeric or value error






Thanks
Christian
Re: UTL_HTTP and wired ORA-06502: PL/SQL: numeric or value error [message #475855 is a reply to message #475837] Sat, 18 September 2010 04:39 Go to previous message
cikic
Messages: 12
Registered: September 2006
Location: Austria
Junior Member
Ahhh ... simply found out varcahr2(4000) is too small for

utl_http.read_line(resp, value, TRUE);

declaring "value" as clob solved the issue.

Thanks
Chris
Previous Topic: union all
Next Topic: Exception is not raising
Goto Forum:
  


Current Time: Sat Sep 06 21:43:57 CDT 2025