Skip to content

Instantly share code, notes, and snippets.

View brunkb's full-sized avatar

Ben Brunk brunkb

  • Minnesota
View GitHub Profile
@brunkb
brunkb / ensure_json.sql
Created June 8, 2015 18:27
Oracle 12 ensure JSON constraint
ALTER myclobs ADD CONSTRAINT ensure_json CHECK (data IS JSON);
@brunkb
brunkb / clob_insert_example2.sql
Last active August 29, 2015 14:22
CLOB Insert Example 2
--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,
SELECT * FROM myclobs
where dbms_lob.instr(data,'Stevenson') >= 1
@brunkb
brunkb / clob_insert.sql
Created June 8, 2015 04:09
CLOB Insert
-- 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,
@brunkb
brunkb / clob_example_create.sql
Last active August 29, 2015 14:22
CLOB Create
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;
@brunkb
brunkb / clob_chunk.sql
Created June 8, 2015 04:07
Chunking up large JSON
DECLARE
json CLOB := 'JSON chunk 1' || 'JSON chunk 2' || 'JSON chunk 3';
BEGIN
insert into myclobs (data, date_created) values(json, SYSDATE);
END;
@brunkb
brunkb / clob_delete.sql
Created June 8, 2015 04:06
Delete CLOB
DELETE FROM myclobs where id=21
update myclobs set data = '{ "changingTheJSON": "Test" }' where id=2
@brunkb
brunkb / clob_advanced_update.sql
Last active August 29, 2015 14:22
CLOB Advanced Update
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;
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