SYSTOOLS HTTP SQL Functions

For some time now you can make HTTP requests with SQL via some UDFs. But there are some things to consider when using them.

CCSID

You may encounter a character conversion error when executing your program though the SQL perfectly works in your SQL editor of choice. This is due to some assumptions made by the compiler.

For example it assumes that the host variables are the same CCSID as the job CCSID (in my case no matter how I defined the host variables, even the keyword ccsid did not help).

So when compiling your program you should set the correct CCSID at the job.

  CHGJOB CCSID(273)

HTTP Header

The default headers are not always what you want to use so you should define your own.

SELECT * FROM (Values(
    SYSTOOLS.HTTPGETCLOB( 
        'http://localhost/book?isbn=1234567890',
        '<httpHeader><header name="Accept" value="application/xml"/><header name="Content-Type" value="application/xml"/></httpHeader>')));

For VERBOSE functions you can also add “includeErrorMsg=true” as and XML attribute to “httpHeader” to get the HTTP message body when a HTTP response is not ok else the message body will be empty.

Resources