Search code examples
sqlrpglewebsphere

Error SQL0204 - Not found HTTPCLOB in SYSTOOOLS type *N


I am trying to use HTTPCLOB function to issue a POST request to a web service, but when I run the program I get the error as in the title, no matter my efforts to match the fields' type of my SQL statement to those of the function. Here D-specifications:

D url             s           1024a   varying             
D httpHeader      s           1024a   varying inz         
D requestMsg      s          32000a   varying inz         
D resHttpHeader   s          32000a   varying inz         
D resMsg          s          32000a   varying inz         

This is the SQL statement:

url = 'https://labelservice.gls-italy.com/AddParcel';          
requestMsg = 'XMLInfoParcel: ' + xmlData;                      
httpHeader = 'Content-Type: application/x-www-form-urlencoded;'
           + ' Content-Length: ' + %char(%len(requestMsg))     
           ;                                                   
exec sql                                         
  select cast(responseMsg as clob(2G))           
  //   , cast(responseHttpHeader as varchar(512))
  into :resMsg                                   
  // , :resHttpHeader                            
  from table(systoools.HTTPCLOB(                 
          URL => cast(:url                       
                 as varchar(2048)),              
          HTTPMETHOD => 'POST',                  
          HTTPHEADER => cast(:httpHeader         
                 as clob(10K)),                  
          REQUESTMSG => cast(:requestMsg         
                 as clob(2G))                    
             )                                   
       ) as httpRequest                          
;                                                

where xmlData is an xml-variabile with some content in it. I assume there might be other errors because this is my first try using this function. Anyway, as for the IBM documentation here https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzajq/rzajqudfhttpclob.htm variables' types match. What am I doing wrong?


Solution

  • So, the first error was a typo, then when the function is used as a table in the from clause the verbose version should be used instead.