Permalink
Browse files

added first few sources as a test

  • Loading branch information...
1 parent d7d054f commit 41f2b0d7b0974901d1e17c6904160e786d0dc217 @tardate committed Jul 8, 2008
Showing with 412 additions and 0 deletions.
  1. +88 −0 clob-cdata-nonschema.sql
  2. +96 −0 clob-cdata-schema.sql
  3. +96 −0 clob-cdata-small.sql
  4. +132 −0 clob-cdata.pl
  5. BIN generator-taxonomy.ods
@@ -0,0 +1,88 @@
+--
+-- demonstrates generating an XML structure with large >32k? CLOB string elements
+-- see discussion at http://forums.oracle.com/forums/thread.jspa?threadID=476322
+--
+-- $Id: clob-cdata-nonschema.sql,v 1.1 2007/02/19 08:40:01 paulg Exp $
+-- author: Paul Gallagher gallagher.paul@gmail.com
+--
+
+CREATE TABLE x1 (item varchar(25) primary key, bigdata clob);
+
+CREATE OR REPLACE TYPE x1_t AS OBJECT
+(Holder varchar(25),BookData CLOB);
+/
+
+CREATE OR REPLACE VIEW vx1 OF XMLTYPE
+WITH OBJECT ID (ExtractValue(sys_nc_rowinfo$, '/ROW/HOLDER')) AS
+SELECT sys_XMLGen(x1_t(x.item, x.bigdata)) from x1 x;
+
+
+
+-- insert some test data
+
+INSERT INTO x1 VALUES ('mysample',
+'<?xml version="1.0" encoding="ISO-8859-1"?>
+<FamilyHistory>
+ <Family>
+ <Sponsor>
+ <Name>
+ <Last>Jones</Last>
+ <First>Tom</First>
+ </Name>
+ <SSN>123456781</SSN>
+ </Sponsor>
+ <Children>
+ <Child>
+ <Name>
+ <Last>Smith</Last>
+ <First>Sandra</First>
+ </Name>
+ <SSN>123456783</SSN>
+ <Allergies>
+ <Allergy>
+ <Allergen>Dust</Allergen>
+ <TreatmentType>Injection</TreatmentType>
+ <Treatments>
+ <Treatment>
+ <Date>20040118</Date>
+ <Reaction>None</Reaction>
+ </Treatment>
+ <Treatment>
+ <Date>20040220</Date>
+ <Reaction>Redness</Reaction>
+ </Treatment>
+ </Treatments>
+ </Allergy>
+ <Allergy>
+ <Allergen>Ragweed</Allergen>
+ <Treatment>None</Treatment>
+ </Allergy>
+ </Allergies>
+ </Child>
+ <Child>
+ <Name>
+ <Last>Jones</Last>
+ <First>Carolyn</First>
+ </Name>
+ <SSN>123456782</SSN>
+ </Child>
+ </Children>
+ </Family>
+</FamilyHistory>');
+
+
+SELECT
+ extractvalue(x.SYS_NC_ROWINFO$,'/ROW/HOLDER') as holder
+ ,'xml_length: ' || dbms_lob.getlength(x.SYS_NC_ROWINFO$.getclobval()) as xml_length
+FROM vx1 x;
+
+set long 2000
+set pages 100
+PROMPT "selecting from xmltype view:"
+select * from vx1;
+
+
+-- cleanup
+DROP VIEW vx1;
+DROP TYPE x1_t;
+DROP TABLE x1;
View
@@ -0,0 +1,96 @@
+--
+-- demonstrates generating an XML structure with large >32k? CLOB string elements
+-- see discussion at http://forums.oracle.com/forums/thread.jspa?threadID=476322
+--
+-- $Id: clob-cdata-schema.sql,v 1.1 2007/02/19 09:26:27 paulg Exp $
+-- author: Paul Gallagher gallagher.paul@gmail.com
+--
+
+CREATE TABLE x1 (item varchar(25) primary key, bigdata clob);
+
+CREATE OR REPLACE TYPE x1_t AS OBJECT
+(Holder varchar(25),BookData CLOB);
+/
+
+exec dbms_xmlschema.registerSchema('http://clob-cdata-schema/x1_t.xsd' ,DBMS_XMLSchema.generateSchema('SCOTT','X1_T'), TRUE, FALSE, FALSE, FALSE);
+
+CREATE OR REPLACE VIEW vx1 OF XMLTYPE
+XMLSCHEMA "http://clob-cdata-schema/x1_t.xsd" ELEMENT "X1_T"
+WITH OBJECT ID (ExtractValue(sys_nc_rowinfo$, '/ROW/HOLDER')) AS
+SELECT x1_t(x.item, x.bigdata) from x1 x;
+
+
+
+
+-- insert some test data
+
+insert into x1 values('test1','<![CDATA[some stuff]]>');
+insert into x1 values('test2','Some stuff & <b>with</b> illegal chars');
+INSERT INTO x1 VALUES ('mysample',
+'<FamilyHistory>
+ <Family>
+ <Sponsor>
+ <Name>
+ <Last>Jones</Last>
+ <First>Tom</First>
+ </Name>
+ <SSN>123456781</SSN>
+ </Sponsor>
+ <Children>
+ <Child>
+ <Name>
+ <Last>Smith</Last>
+ <First>Sandra</First>
+ </Name>
+ <SSN>123456783</SSN>
+ <Allergies>
+ <Allergy>
+ <Allergen>Dust</Allergen>
+ <TreatmentType>Injection</TreatmentType>
+ <Treatments>
+ <Treatment>
+ <Date>20040118</Date>
+ <Reaction>None</Reaction>
+ </Treatment>
+ <Treatment>
+ <Date>20040220</Date>
+ <Reaction>Redness</Reaction>
+ </Treatment>
+ </Treatments>
+ </Allergy>
+ <Allergy>
+ <Allergen>Ragweed</Allergen>
+ <Treatment>None</Treatment>
+ </Allergy>
+ </Allergies>
+ </Child>
+ <Child>
+ <Name>
+ <Last>Jones</Last>
+ <First>Carolyn</First>
+ </Name>
+ <SSN>123456782</SSN>
+ </Child>
+ </Children>
+ </Family>
+</FamilyHistory>');
+
+
+--
+set long 2000
+set pages 100
+
+PROMPT "selecting from xmltype view:"
+select x.SYS_NC_ROWINFO$.getclobval() from vx1 x;
+
+SELECT
+ 'xml_length: ' || dbms_lob.getlength(x.SYS_NC_ROWINFO$.getclobval()) as xml_length
+FROM vx1 x;
+
+
+
+-- cleanup
+DROP VIEW vx1;
+exec dbms_xmlschema.deleteSchema('http://clob-cdata-schema/x1_t.xsd');
+DROP TYPE x1_t;
+DROP TABLE x1;
View
@@ -0,0 +1,96 @@
+--
+-- demonstrates generating an XML structure with small <32k? CLOB CDATA section
+-- see discussion at http://forums.oracle.com/forums/thread.jspa?threadID=476322
+-- see also:
+-- XMLCdata http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/functions216.htm#CIHFBEGB
+--
+-- $Id: clob-cdata-small.sql,v 1.1 2007/02/19 08:33:50 paulg Exp $
+-- author: Paul Gallagher gallagher.paul@gmail.com
+--
+
+
+CREATE TABLE x1 (item varchar(25) primary key, bigdata clob);
+
+
+-- this is ok with bigdata <=4000 chars
+
+SELECT XMLELEMENT("FamilyHistory",
+ XMLATTRIBUTES ( x.item as "ID"),
+ XMLCData( x.bigdata)) AS "FamilyHistory Doc"
+ FROM x1 x
+ WHERE x.item = 'mydata';
+
+CREATE OR REPLACE VIEW vx1 AS
+SELECT
+ XMLELEMENT(FAMILYHISTORY,
+ XMLATTRIBUTES ( x.item as ID ),
+ XMLCData( x.bigdata )
+ ) AS FamilyHistory
+FROM x1 x;
+
+
+-- insert some test data
+
+INSERT INTO x1 VALUES ('mysample',
+'<?xml version="1.0" encoding="ISO-8859-1"?>
+<FamilyHistory>
+ <Family>
+ <Sponsor>
+ <Name>
+ <Last>Jones</Last>
+ <First>Tom</First>
+ </Name>
+ <SSN>123456781</SSN>
+ </Sponsor>
+ <Children>
+ <Child>
+ <Name>
+ <Last>Smith</Last>
+ <First>Sandra</First>
+ </Name>
+ <SSN>123456783</SSN>
+ <Allergies>
+ <Allergy>
+ <Allergen>Dust</Allergen>
+ <TreatmentType>Injection</TreatmentType>
+ <Treatments>
+ <Treatment>
+ <Date>20040118</Date>
+ <Reaction>None</Reaction>
+ </Treatment>
+ <Treatment>
+ <Date>20040220</Date>
+ <Reaction>Redness</Reaction>
+ </Treatment>
+ </Treatments>
+ </Allergy>
+ <Allergy>
+ <Allergen>Ragweed</Allergen>
+ <Treatment>None</Treatment>
+ </Allergy>
+ </Allergies>
+ </Child>
+ <Child>
+ <Name>
+ <Last>Jones</Last>
+ <First>Carolyn</First>
+ </Name>
+ <SSN>123456782</SSN>
+ </Child>
+ </Children>
+ </Family>
+</FamilyHistory>');
+
+select
+ extract(FamilyHistory,'/FAMILYHISTORY/@ID') as id
+ ,dbms_lob.getlength(xmltype.getclobval(FamilyHistory)) as xml_length
+from vx1;
+
+set long 2000
+set pages 100
+PROMPT "selecting from xmltype view:"
+select * from vx1;
+
+-- cleanup
+DROP VIEW vx1;
+DROP TABLE x1;
Oops, something went wrong.

0 comments on commit 41f2b0d

Please sign in to comment.