-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE TABLE mik (
    id INTEGER NOT NULL,
    doc JSON,
    PRIMARY KEY(id)
);
INSERT INTO mik VALUES(1, '{}');
SELECT doc FROM mik WHERE id = 1;
UPDATE mik SET doc = JSON_SET(doc, '$.a', 123) WHERE id = 1;
SELECT doc FROM mik WHERE id = 1;
UPDATE mik SET doc = JSON_SET(doc, '$.b', 'ABC') WHERE id = 1;
SELECT doc FROM mik WHERE id = 1;
UPDATE mik SET doc = JSON_SET(doc, '$.c', JSON_ARRAY(123, 456)) WHERE id = 1;
SELECT doc FROM mik WHERE id = 1;
UPDATE mik SET doc = JSON_SET(doc, '$.d', JSON_ARRAY('ABC', 'DEF')) WHERE id = 1;
SELECT doc FROM mik WHERE id = 1;
UPDATE mik SET doc = JSON_SET(doc, '$.e', JSON_OBJECT('foo', 123, 'bar', 'ABC')) WHERE id = 1;
SELECT doc FROM mik WHERE id = 1;
DROP TABLE mik;
