Bookmark and Share
RSS

Recent Posts

Additional Support for JSON

April 24, 2018

The JSON_VAL function provides an SQL interface to extract and retrieve JSON data into SQL data types from BSON objects. BSON is a standardized binary representation format for serializing JSON documents. It allows for fast traversal of JSON documents.
 
JSON_VAL returns an element of a JSON document that's identified by the JSON field name specified in search-string. The value of the JSON element is returned in the data type and length that is specified in result-type.
 
Example function syntax:
 
>>-JSON_VAL--(--json-value--,--search-string--,--result-type--)-><
 
The IBM Knowledge Center has more about this function and all the options.
 
To make it possible to meet the requirements imposed by web and mobile applications, Db2 12 provides two new options for working with JSON: the Java driver for the JSON API, or SQL extensions.
 
Referring to the previous sample syntax, (json-value) is no longer required to be a BLOB column. With Db2 12, the json-value parameter can now be one of the following:
  • a view column 
  • a CASE expression 
  • a table expression with UNION ALL 
  • a trigger transition variable 
  • a SQL PL variable or parameter.
For more about JSON programming, see this Knowledge Center doc. Make sure to expand the table of contents so you can view all of the chapters:
Here's a final Knowledge Center tutorial on using an SQL interface to handle JSON data.
 

Posted April 24, 2018| Permalink

comments powered by Disqus