Inserting JSON data into a table

You can use the JSON2BSON function to insert JSON data into a table.

About this task

The JSON2BSON function is used to convert a value into its binary representation before it is inserted into a table. JSON2BSON requires a CLOB data type as the single input parameter.

Procedure

To insert JSON data into a table:

Issue the INSERT SQL statement and specify the JSON2BSON function.

Example

The following example inserts a JSON document string into the table:
INSERT INTO CLAIMS (CLAIM_ID, POLICY_NUM, CUSTOMER_ID, STATUS, CALL_RECORDS)
            VALUES ( 'AB0033789',
                     'GL0000336512',
                     '09736814',
                     'CLOSED',
                     SYSTOOLS.JSON2BSON('{"calls": [ {"dateOfCall": "2014-02-26", "associate": "Steven Barnes",
                                          "conversationNotes": "Customer provided details of accident and witness
                                          contact information.  Stated that her local agent was unavailable."}  ],
                                          "satisfactionSurveyResult":"needs improvement"  }'
                                        ) 
                     );