This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER myclobs ADD CONSTRAINT ensure_json CHECK (data IS JSON); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Fake data generated by: http://json-generator.appspot.com/ | |
insert into myclobs (data, date_created) values (to_clob('[ | |
{ | |
"_id": "556e52fc21aa6202ee1aac18", | |
"index": 0, | |
"guid": "dd60b0a8-2bb8-4dae-83b4-1940b2e47f9c", | |
"isActive": false, | |
"balance": "$3,616.96", | |
"picture": "http://placehold.it/32x32", | |
"age": 40, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM myclobs | |
where dbms_lob.instr(data,'Stevenson') >= 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Fake data generated by: http://json-generator.appspot.com/ | |
insert into myclobs (data, date_created) values (' | |
{ | |
"_id": "556e52fc21aa6202ee1aac18", | |
"index": 0, | |
"guid": "dd60b0a8-2bb8-4dae-83b4-1940b2e47f9c", | |
"isActive": false, | |
"balance": "$3,616.96", | |
"picture": "http://placehold.it/32x32", | |
"age": 40, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table MYCLOBS | |
( | |
id number not null, | |
data clob, | |
date_created timestamp, | |
CONSTRAINT PK_MYCLOBS PRIMARY KEY (id) | |
); | |
-- An auto-generated sequence for the ids | |
CREATE SEQUENCE myclob_seq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
json CLOB := 'JSON chunk 1' || 'JSON chunk 2' || 'JSON chunk 3'; | |
BEGIN | |
insert into myclobs (data, date_created) values(json, SYSDATE); | |
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM myclobs where id=21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update myclobs set data = '{ "changingTheJSON": "Test" }' where id=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO myclobs (data, date_created) VALUES('<attrs><attr name="name"><string>Barney</string></attr></attrs>', | |
SYSDATE); | |
UPDATE myclobs m SET data=UPDATEXML( | |
XMLTYPE.createXML(data),'/attrs/attr[@name="name"]/string /text()','Gumble').getClobVal() | |
WHERE m.id=26; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PricingServiceFirstTry { | |
// these dependencies would normally be injected | |
AuthenticationProvider auth = new AuthenticationProvider() | |
InventorySystem inv = new InventorySystem() | |
String username = 'test' | |
String password = 'test' | |
def logError(String msg) { println msg } // simulated logger | |