sql >> Base de Datos >  >> RDS >> Oracle

Almacene grandes archivos JSON en Oracle DB

CLOB tener un límite de tamaño de 4G

Pero la limitación aquí es con UTL_HTTP.read_text que devuelve el resultado como un VARCHAR2 (usted tiene un implícito conversión aquí).

Para recuperar fácilmente objetos de texto grandes de la web, probablemente necesite HttpUriType.getClob

Si por alguna razón quieres quedarte con UTL_HTTP , tendrá que hacer un bucle para leer sus datos fragmento por fragmento. Algo así:

BEGIN
  ...
  l_clob           CLOB;
  l_text           VARCHAR2(32767);
BEGIN
  DBMS_LOB.createtemporary(l_clob, FALSE);

  ...
  l_http_request  := UTL_HTTP.begin_request(your_URI);
  l_http_response := UTL_HTTP.get_response(l_http_request);

  -- Loop to read data chunk by chunk up to the end
  BEGIN
    LOOP
      UTL_HTTP.read_text(l_http_response, l_text, 32766);
      DBMS_LOB.writeappend (l_clob, LENGTH(l_text), l_text);
    END LOOP;
  EXCEPTION
    WHEN UTL_HTTP.end_of_body THEN
      UTL_HTTP.end_response(l_http_response);
  END;

Consulte http:// oracle-base.com/articles/misc/retrieving-html-and-binaries-into-tables-over-http.php vor varios ejemplos