HTTPGETBLOBFILE and HTTPGETCLOBFILE
The HTTPGETBLOBFILE and HTTPGETCLOBFILE REST functions retrieve a binary or text-based resource from the specified URL through an HTTP GET request. The resource is stored in a temporary file, and the path of the temporary file is returned as VARCHAR data. The character set is converted into the database code page if necessary.
Tip: The sample HTTP user-defined functions are intended
to be used within Db2 SQL applications to
access remote non-Db2 REST-based services
through SQL statements. Do not confuse them with Db2 native REST services, which supports using a
REST-based interface to interact with Db2
data from web, mobile, and cloud applications.
The schema is DB2XML.
- url
- Specifies the URL of the resource that is being accessed. This argument is defined as a VARCHAR(2048) value.
- httpHeader
- Specifies an optional header XML document. This argument is defined as a
CLOB(10K) value.
The XML header document can provide additional HTTP header values in the following format:
<httpHeader headerAttribute="headerAttributeValue"> <header name="name" value="value" /> </httpHeader>
- headerAttribute
- Specify any of the following optional attributes:
- connectTimeout
- Specifies an integer value for the connection timeout threshold in milliseconds.
- readTimeout
- Specifies an integer value for the read timeout threshold in milliseconds.
- followRedirects
- Specifies whether redirects should be followed. This is a boolean value.
- useCaches
- Specifies whether caches should be used. This is a boolean value.
- responseMsgFormat
- Specifies the header attribute value errorTagged, to indicate that when the server returns an
error message to the user-defined function, the user-defined function returns the following values
to the caller:
- SQLCODE 0
- The error message from the server, in the following
format:
<error httprc="{HTTP-status-code}"> {error-message-returned-from-server} </error>
- headerAttributeValue
- Specifies a value for the headerAttribute. Separate headerAttribute and headerAttributeValue combinations with single spaces.
- name
- The header name.
- value
- The header value.