Skip to content

Instantly share code, notes, and snippets.

Last active Nov 12, 2020
What would you like to do?
Пример работы с подсказками DaData на PL/SQL (Oracle)
http_req utl_http.req;
http_resp utl_http.resp;
query varchar2(32767);
query_raw RAW(512);
resp_text varchar2(32767);
query := '{ "query": "7719402047", "count": 1 }';
query := convert(query, 'UTF8');
http_req := utl_http.begin_request('', '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);

This comment has been minimized.

Copy link

@Zhigalin Zhigalin commented Nov 12, 2020

Тут у вас запрос остаётся висеть, закрывать надо


This comment has been minimized.

Copy link
Owner Author

@nalgeon nalgeon commented Nov 12, 2020

Спасибо, добавил.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment