Last active
December 20, 2022 10:12
-
-
Save nalgeon/455736c5073c48edb4bde1264fa6b2d7 to your computer and use it in GitHub Desktop.
Пример работы с подсказками DaData на PL/SQL (Oracle)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
http_req utl_http.req; | |
http_resp utl_http.resp; | |
query varchar2(32767); | |
query_raw RAW(512); | |
resp_text varchar2(32767); | |
begin | |
query := '{ "query": "7719402047", "count": 1 }'; | |
query := convert(query, 'UTF8'); | |
http_req := utl_http.begin_request('http://suggestions.dadata.ru/suggestions/api/4_1/rs/findById/party', 'POST', 'HTTP/1.1'); | |
utl_http.set_header(http_req, 'Content-Type', 'application/json'); | |
utl_http.set_header(http_req, 'Accept', 'application/xml'); | |
utl_http.set_header(http_req, 'Authorization', 'Token API_KEY'); | |
utl_http.set_header(http_req, 'Content-Length', lengthb(query)); | |
query_raw := utl_raw.cast_to_raw(query); | |
utl_http.write_raw(http_req, query_raw); | |
http_resp := utl_http.get_response(http_req); | |
utl_http.set_body_charset(http_resp, 'UTF-8'); | |
utl_http.read_text(http_resp, resp_text); | |
dbms_output.put_line('HTTP response status code: ' || http_resp.status_code); | |
dbms_output.put_line('HTTP response reason: ' || http_resp.reason_phrase); | |
dbms_output.put_line('HTTP response text: ' || resp_text); | |
utl_http.end_response(http_resp); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gekchuk просто меняй varchar на clob и raw на блоб, оно работает