Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DB2 Result set JSON Format

451 views
Skip to first unread message

bruno.almeida

unread,
Aug 19, 2015, 9:45:06 AM8/19/15
to
Hello friends,

DB2 LUW v10.1 Fixpack 5

Is possible retrieve a conventional result set, in a JSON format?

Ex.

Conventional


MACHINE_ID MAC_ADDRESS IP_ADDRESS
------------------ ----------------- -----------------
0000212AB9CC247C52 00:01:02:D1:ED:CC 10.2.34.129
0000212AB9CC247C52 00:00:21:2A:B9:CC 192.168.0.1


JSON

{"MACHINE_ID": "0000212AB9CC247C52",
"MAC_ADDRESS": ["00:01:02:D1:ED:CC", "00:00:21:2A:B9:CC"],
"IP_ADDRESS": ["10.2.34.129","192.168.0.1"]
}

Regards,
Bruno.

Larry

unread,
Aug 19, 2015, 11:19:01 PM8/19/15
to
Perhaps this might be helpful:
http://www.ibm.com/developerworks/data/library/techarticle/dm-1306nosqlforjson1/index.html

But you'll need DB2 10.5 fixpack 1.

--
Larry E.

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Jeremy Rickard

unread,
Aug 20, 2015, 1:14:21 AM8/20/15
to
As Larry has just pointed out, DB2 10.5 has JSON support. As well as the developerWorks articles see the DB2 Knowledge Center at: http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.swg.im.dbclient.json.doc/doc/c0061252.html?lang=en

However, if you want to be able to render any result set as a single JSON document or even as a collection of similar JSON documents then I suspect you are out of luck. I haven't tried it out, but I think the JSON support only extends to working on a schema designed to hold JSON objects. It does not appear as deeply integrated into the DB2 engine as SQL and XML.

Would it not be fairly trivial to write a Java routine yourself, to execute any query and return the result set as a JSON document?


Jeremy Rickard

bruno.almeida

unread,
Aug 21, 2015, 1:39:38 PM8/21/15
to
Thank you Jeremy and Larry.

I will write a Java routine to return the result set.

Cheers.
0 new messages