JSON sql support
Posted in 2014
Topics: Installation, Setup & Upgrades, Server Administration
Hi.
I installed 12.10.FC2 and I can happily create a table with the new JSON
datatype:
#echo "create table testjson (t json)"|dbaccess $DB
Database selected.
Table created.
Database closed.
However, I can't seem to find any reference to the JSON/BSON datatypes in the
12.10 Knowledge center, except in a chapter called "IBM Informix JSON
compatibility". Nothing in SQL datatypes etc. Are these datatypes only
accessible through the MongoDB interface and not directly through SQL? How do
I insert for example the json string
{"simple":234,"record":{"id":234,"name":"Barton"},"array":[234,2837,null,12837]}
into my table?
Am I missing something?
Best regards,
-Snorri
Unfortunately the documentation for the JSON & BSON data types is not yet
ready for distribution. I know that IBM is working hard to get it out.
First thing I can tell you is to insert it simply:
insert into testjson values ('{"simple":234,"record":{"id":
234,"name":"Barton"},"array":[234,2837,null,12837]}');
> select t from testjson;
t
{"simple":234,"record":{"id":234,"name":"Barton"},"array":[234,2837,null,128
37]}
1 row(s) retrieved.
If you look at the MongoDB presentation from the IOD conference (
http://www.slideshare.net/journalofinformix/nosql-deepdive-with-informix-nosql-i
od-2013),
you will find functions you can use to extract the data from the JSON
column's fields. One example:
select bson_value_lvarchar( t, "simple" )
from testjson
where bson_value_int( t, "simple" ) = 234;
Art
Art S. Kagel, Principal Consultant
ASK Database Management
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
On Fri, Feb 21, 2014 at 9:58 AM, SNORRI BERGMANN <snorri@init.is> wrote:
> Hi.
>
> I installed 12.10.FC2 and I can happily create a table with the new JSON
> datatype:
>
> #echo "create table testjson (t json)"|dbaccess $DB
>
> Database selected.
>
> Table created.
>
> Database closed.
>
> However, I can't seem to find any reference to the JSON/BSON datatypes in
> the
> 12.10 Knowledge center, except in a chapter called "IBM Informix JSON
> compatibility". Nothing in SQL datatypes etc. Are these datatypes only
> accessible through the MongoDB interface and not directly through SQL? How
> do
> I insert for example the json string
>
>
>
{"simple":234,"record":{"id":234,"name":"Barton"},"array":[234,2837,null,12837]}
> into my table?
> Am I missing something?
>
> Best regards,
> -Snorri
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--089e01175e7d5cb5c404f2ed0b2c
Thanks a lot Art. This clarifies things a bit :) Have a nice weekend, -Snorri
Related threads
- Enterprise Replication recovery slow on Solaris
- checkpoint was stalled
- onbar restore LTAPEDEV=/dev/null
- Tech Tip du Jour: Pricing
- Date Type- First wednesday of a month