代码之家  ›  专栏  ›  技术社区  ›  Mustapha George

IBM DB/2 i-SQL从JSON\表中选择JSON\ VAL“

  •  0
  • Mustapha George  · 技术社区  · 7 年前

    我正在尝试通过使用“SQL SELECT JSON\u VAL FROM JSON\u Table”的示例进行操作 从远程web服务获取数据。我不断得到相同错误的变化。。。

    嵌入语句中缺少子句的位置17。

    谢谢!

    // JSON_TABLE : used to extract values from that JSON object into relational data.   
    // '$' :  used as the outermost SQL/JSON path expression,                            
    //        the column definitions will use the existing JSON object                   
    //        as their context item. Because '$' only references one item in the         
    //        object, this use of JSON_TABLE will only produce one row.                  
    //        After the outermost SQL/JSON path expression, the columns are defined.     
    
    
         D myString     s           5500a    
    
          Exec SQL SELECT JSON_VAL FROM Json_Table(                            
          Systools.HttpPostClob(                                               
            'http://10.10.10.10:8099/dir/dir/pgm',              
            '<httpHeader>' +                                                   
            '<header name="Content-Type" value="application/json"/>' +         
            '</httpHeader>',  :myString       
            // '</httpHeader>' INTO :myString    << NO   
            // '</httpHeader>') INTO :myString    << NO
           ), '$' COLUMNS(JSON_VAL VARCHAR(1000) PATH '$.json')) as x ;        
    
    
           ParmOut = myString;
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   jmarkmurphy    7 年前

    SELECT INTO 语法如下:

    exec sql
      select ...
        into ...
        from ...
    

    exec sql
      select json_val
        into :mystring
        from json_table(
          systools.HttpPostClob(
            'http://10.10.10.10:8099/dir/dir/pgm',              
            '<httpHeader>' +                                                   
            '<header name="Content-Type" value="application/json"/>' +         
            '</httpHeader>'
          ), '$' COLUMNS(JSON_VAL VARCHAR(1000) PATH '$.json')) as x ;
    

    问题是,我在DB2forIv7.3文档中找不到HttpPostClob()。如果不滚动您自己的存储过程,您可能无法在该平台上使用它。