Получение ставки рефинансирования с сайта cbr.ru 
	   
	     | 
   
 
	
		| Предыдущая тема :: Следующая тема   | 
	 
	
	
		| Автор | 
		Сообщение | 
	 
	
		smirnovan Участник со стажем
 
  Вступление в Клуб: 10.12.2014
  | 
		
			
				 Чт Янв 11, 2018 10:58   Получение ставки рефинансирования с сайта cbr.ru | 
				     | 
			 
			
				Полезность: 6 
  | 
			 
			
				Может кому будет полезно. Ставку рефинансирования можно получить вот таким способом:
 
 
 	  | Код: | 	 		  procedure GetFinRate
 
is
 
 
  soap_req         clob default EMPTY_CLOB;
 
  http_req          utl_http.REQ;
 
  http_resp       utl_http.RESP;
 
  answer         clob default EMPTY_CLOB;
 
  buff              VARCHAR2(32767);
 
 
  xml            XMLType;
 
 
  date_beg         date;
 
  FinRate         number;
 
  FinRate_set      number;
 
  msg            varchar2(100);
 
 
begin
 
 
     soap_req := '<?xml version="1.0" encoding="utf-8"?>'||NL$
 
              ||'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'||NL$
 
              ||'<soap12:Body>'||NL$
 
              ||'<MainInfoXML xmlns="http://web.cbr.ru/" />'||NL$
 
              ||'</soap12:Body>'||NL$
 
              ||'</soap12:Envelope>';
 
 
   utl_http.set_body_charset('utf-8');
 
   
 
   http_req := utl_http.begin_request('http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx', 'POST', 'HTTP/1.1');
 
 
   utl_http.set_header(http_req, 'Content-Type', 'application/soap+xml; charset=utf-8');
 
      utl_http.set_header(http_req, 'Content-Length', length(soap_req));
 
      utl_http.set_header(http_req, 'SOAPAction', 'http://web.cbr.ru/MainInfoXML');
 
   
 
   utl_http.write_text(http_req, soap_req);
 
   
 
   http_resp := utl_http.get_response(http_req);
 
   
 
     IF http_resp.status_code = 200 THEN
 
 
       DBMS_LOB.CREATETEMPORARY(answer, false);
 
       BEGIN
 
         LOOP
 
           utl_http.READ_TEXT(http_resp, buff);
 
           DBMS_LOB.WRITEAPPEND(answer, length(buff), buff);
 
         END LOOP;
 
         utl_http.END_RESPONSE(http_resp);
 
       EXCEPTION
 
          WHEN  utl_http.END_OF_BODY THEN
 
                utl_http.END_RESPONSE(http_resp);
 
       END;
 
     
 
    ELSE
 
      utl_http.END_RESPONSE(http_resp);
 
    END IF;
 
 
    IF answer is not NULL then
 
 
        xml      := XMLType.CreateXML(ltrim(replace(answer,' xmlns=""','')));
 
        FinRate  := XMLType.GetStringVal(xml.extract('/soap:Envelope/soap:Body/MainInfoXMLResponse/MainInfoXMLResult/RegData/stavka_ref/text()','xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://web.cbr.ru/" xmlns=""'));
 
        msg      := XMLType.GetStringVal(xml.extract('/soap:Envelope/soap:Body/MainInfoXMLResponse/MainInfoXMLResult/RegData/stavka_ref/@Title','xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://web.cbr.ru/" xmlns=""'));
 
        date_beg := to_date(XMLType.GetStringVal(xml.extract('/soap:Envelope/soap:Body/MainInfoXMLResponse/MainInfoXMLResult/RegData/stavka_ref/@Date','xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://web.cbr.ru/" xmlns=""')), 'dd.mm.yyyy');
 
        
 
    END IF;
 
 
    FinRate_set := ::[PRC_SCHEME].[LIB].GetPrcRate( ::[PRC_SCHEME]([COD] = 'ЦБ'), [SYSTEM].op_date, 0, 0, false, false);
 
 
end; | 	  
 
 
Что дальше с этим делать каждый решает сам. Можно менять в соответствующих схемах, можно просто уведомлялку. | 
			 
		  | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
Вы не можете начинать темы Вы не можете отвечать на сообщения Вы не можете редактировать свои сообщения Вы не можете удалять свои сообщения Вы не можете голосовать в опросах
  | 
   
 
		 |