Michael B - 2014-03-03

I am trying to get this project to work with oracle 9i. I almost have it working but for some reason its messing up on parsing the second object inside of array’s.. Can anyone help me fix this last error ?

I had to replace the regex like function and add a blob to clob function.. I also had to change the regex parts to use the function and move to a bool return using anther function…I also had to move to using a different set of escape characters because 9i does not support the grouping function.

create or replace FUNCTION regexp_like (source_char IN VARCHAR2
, pattern IN VARCHAR2
, match_parameter IN VARCHAR2 DEFAULT NULL)
RETURN INTEGER
AS
/*************

  • Program : regexp_like
  • Version : 1.0
  • Author : Philip Moore
  • Date : 20-JUN-2009 Anno Domini
  • Purpopse : This provides a pseudo "REGEXP_LIKE" operator for Oracle 9iR2
  • Warnings : Do NOT compile in an Oracle 10GR2 database (or above)!
    *************/
    -- Variables
    l_return INTEGER;
    BEGIN
    IF owa_pattern.match (line => source_char
    , pat => pattern
    , flags => match_parameter) THEN
    l_return := 1;
    ELSE
    l_return := 0;
    END IF;
    RETURN l_return;
    END regexp_like;

create or replace FUNCTION regexp_tf(input_num number ) RETURN BOOLEAN
AS
/*************

  • Purpopse : This Converts 1 and 0 to be true false like regex returns normally
  • Warnings : Do NOT compile in an Oracle 10GR2 database (or above)!
    *************/
    BEGIN
    IF input_num = 1 THEN
    return true;
    ELSE
    return false;
    END IF;
    END regexp_tf;

create or replace procedure blob_to_clob(
c IN BLOB,
dest_lob IN OUT NOCOPY CLOB CHARACTER SET ANY_CS,
amount IN INTEGER,
dest_offset IN OUT INTEGER,
src_offset IN OUT INTEGER,
blob_csid IN NUMBER,
lang_context IN OUT INTEGER,
warning OUT INTEGER )
-- typecasts CLOB to BLOB (binary conversion)
IS
pos PLS_INTEGER := 1;
buffer RAW( 32767 );
lob_len PLS_INTEGER := DBMS_LOB.getLength( c );
BEGIN
DBMS_LOB.createTemporary( dest_lob, TRUE );
DBMS_LOB.OPEN( dest_lob, DBMS_LOB.LOB_ReadWrite );
LOOP
buffer := UTL_RAW.cast_to_raw( DBMS_LOB.SUBSTR( c, 16000, pos ) );
IF UTL_RAW.LENGTH( buffer ) > 0 THEN
DBMS_LOB.writeAppend( dest_lob, UTL_RAW.LENGTH( buffer ), buffer );
END IF;
pos := pos + 16000;
EXIT WHEN pos > lob_len;
END LOOP;
--RETURN dest_lob; -- dest_lob is OPEN here
END blob_to_clob;

Path for json_parser.sql
227c227
< while(REGEXP_LIKE(buf, '^[[:alnum:]_]$', 'i')) loop


while(regexp_tf(REGEXP_LIKE(buf, '^[A-Za-z0-9 ]*$', 'i'))) loop

381c381
< if(json_strict = false and REGEXP_LIKE(buf, '^[[:alpha:]]$', 'i')) then


        if(json_strict = false and regexp_tf(REGEXP_LIKE(buf, '^[A-Za-z ]*$', 'i'))) then

396c396
< if(json_strict = false and REGEXP_LIKE(buf, '^[[:alpha:]]$', 'i')) then


        if(json_strict = false and regexp_tf(REGEXP_LIKE(buf, '^[A-Za-z ]*$', 'i')) ) then

405c405
< tokens(tok_indx) := mt('NULL', lin_no, col_no, null); tok_indx := tok_indx + 1;


        tokens(tok_indx) := mt('STRING', lin_no, col_no, null); tok_indx := tok_indx + 1;

411c411
< if(json_strict = false and REGEXP_LIKE(buf, '^[[:alpha:]]$', 'i')) then


        if(json_strict = false and regexp_tf(REGEXP_LIKE(buf, '^[A-Za-z ]*$', 'i')) ) then

455c455
< when json_strict = false and REGEXP_LIKE(buf, '^[[:alpha:]]$', 'i') then


    when json_strict = false and regexp_tf(REGEXP_LIKE(buf, '^[A-Za-z ]*$', 'i')) then

858,859c858

Patch for json_ext.sql
151c151
< if(not regexp_like(buf, '^[[:alnum:]_ ]+', 'c') ) then


    if(not regexp_tf(regexp_like(buf, '^[A-Za-z0-9_]*$', 'c')) ) then

157c157
< while(regexp_like(buf, '^[[:alnum:]_ ]+', 'c') ) loop


    while(regexp_tf(regexp_like(buf, '^[A-Za-z0-9_]*$', 'c')) ) loop

172c172
< elsif (regexp_like(buf, '^(\"|\'')', 'c')) then


    elsif (regexp_tf(regexp_like(buf, '^["]*$', 'c')) or regexp_tf(regexp_like(buf, '^['']*$', 'c')))  then

199c199
< if(not regexp_like(buf, '^[[:alnum:]_ ]+', 'c') ) then


    if(not regexp_tf(regexp_like(buf, '^[A-Za-z0-9_]*$', 'c')) ) then

203c203
< while(regexp_like(buf, '^[[:alnum:]_ ]+', 'c') ) loop


    while(regexp_tf(regexp_like(buf, '^[A-Za-z0-9_]*$', 'c')) ) loop

673c673
< DBMS_LOB.CONVERTTOBLOB(b, c, dbms_lob.lobmaxsize, v_clob_offset, v_blob_offset, 1, v_lang_context, v_warning);


blob_to_clob(b, c, dbms_lob.lobmaxsize, v_clob_offset, v_blob_offset, 1, v_lang_context, v_warning);

794c794
< DBMS_LOB.CONVERTTOBLOB(b, c, dbms_lob.lobmaxsize, v_clob_offset, v_blob_offset, 1, v_lang_context, v_warning);


blob_to_clob(b, c, dbms_lob.lobmaxsize, v_clob_offset, v_blob_offset, 1, v_lang_context, v_warning);

Patch for json_util_pkg.sql
43c43
< Remarks:


Remarks:
48c48
<


69c69
<


73c73,74
< return q'^


return
'
79c80
< Redistribution and use in source and binary forms, with or without modification,


Redistribution and use in source and binary forms, with or without modification,
82,85c83,86
< Redistributions of source code must retain the above copyright notice, this
< list of conditions and the following disclaimer. Redistributions in binary
< form must reproduce the above copyright notice, this list of conditions and the
< following disclaimer in the documentation and/or other materials provided with


Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. Redistributions in binary
form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with
88,96c89,97
< THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
< ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
< WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
< IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
< INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
< BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
< DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
< LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
< OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
114,115c115,116
<
< <!-- Main template for escaping strings; used by above template and for object-properties


<!-- Main template for escaping strings; used by above template and for object-properties
125c126
<


130c131
< <xsl:when test="contains($s,'\')"></xsl:when>


  <xsl:when test="contains($s,'||CHR(TO_NUMBER('27','xx'))||'\\'||CHR(TO_NUMBER('27','xx'))||')">

132c133
< <xsl:with-param name="s" select="concat(substring-before($s,'\'),'\\')"></xsl:with-param>


      <xsl:with-param name="s" select="concat(substring-before($s,'||CHR(TO_NUMBER('27','xx'))||'\\'||CHR(TO_NUMBER('27','xx'))||'),'||CHR(TO_NUMBER('27','xx'))||'\\\\'||CHR(TO_NUMBER('27','xx'))||')"/>

135c136
< <xsl:with-param name="s" select="substring-after($s,'\')"></xsl:with-param>


      <xsl:with-param name="s" select="substring-after($s,'||CHR(TO_NUMBER('27','xx'))||'\\'||CHR(TO_NUMBER('27','xx'))||')"/>

145c146
<


150c151
< <xsl:when test="contains($s,'"')"></xsl:when>


  <xsl:when test="contains($s,'||CHR(TO_NUMBER('27','xx'))||CHR(TO_NUMBER('26','xx'))||'quot;'||CHR(TO_NUMBER('27','xx'))||')">

152c153
< <xsl:with-param name="s" select="concat(substring-before($s,'"'),'\"')"></xsl:with-param>


      <xsl:with-param name="s" select="concat(substring-before($s,'||CHR(TO_NUMBER('27','xx'))||CHR(TO_NUMBER('26','xx'))||'quot;'||CHR(TO_NUMBER('27','xx'))||'),'||CHR(TO_NUMBER('27','xx'))||'\\'||CHR(TO_NUMBER('26','xx'))||'quot;'||CHR(TO_NUMBER('27','xx'))||')"/>

155c156
< <xsl:with-param name="s" select="substring-after($s,'"')"></xsl:with-param>


      <xsl:with-param name="s" select="substring-after($s,'||CHR(TO_NUMBER('27','xx'))||CHR(TO_NUMBER('26','xx'))||'quot;'||CHR(TO_NUMBER('27','xx'))||')"/>

165,169c166,170
<
<



174c175
< <xsl:when test="contains($s,' ')"></xsl:when>


  <xsl:when test="contains($s,'||CHR(TO_NUMBER('27','xx'))||'&#x9;'||CHR(TO_NUMBER('27','xx'))||')">

176c177
< <xsl:with-param name="s" select="concat(substring-before($s,' '),'\t',substring-after($s,' '))"></xsl:with-param>


      <xsl:with-param name="s" select="concat(substring-before($s,'||CHR(TO_NUMBER('27','xx'))||'&#x9;'||CHR(TO_NUMBER('27','xx'))||'),'||CHR(TO_NUMBER('27','xx'))||'\t'||CHR(TO_NUMBER('27','xx'))||',substring-after($s,'||CHR(TO_NUMBER('27','xx'))||'&#x9;'||CHR(TO_NUMBER('27','xx'))||'))"/>

180c181
< <xsl:when test="contains($s,' ')"></xsl:when>


  <xsl:when test="contains($s,'||CHR(TO_NUMBER('27','xx'))||'&#xA;'||CHR(TO_NUMBER('27','xx'))||')">

182c183
< <xsl:with-param name="s" select="concat(substring-before($s,' '),'\n',substring-after($s,' '))"></xsl:with-param>


      <xsl:with-param name="s" select="concat(substring-before($s,'||CHR(TO_NUMBER('27','xx'))||'&#xA;'||CHR(TO_NUMBER('27','xx'))||'),'||CHR(TO_NUMBER('27','xx'))||'\n'||CHR(TO_NUMBER('27','xx'))||',substring-after($s,'||CHR(TO_NUMBER('27','xx'))||'&#xA;'||CHR(TO_NUMBER('27','xx'))||'))"/>

186c187
< <xsl:when test="contains($s,' ')"></xsl:when>


  <xsl:when test="contains($s,'||CHR(TO_NUMBER('27','xx'))||'&#xD;'||CHR(TO_NUMBER('27','xx'))||')">

188c189
< <xsl:with-param name="s" select="concat(substring-before($s,' '),'\r',substring-after($s,' '))"></xsl:with-param>


      <xsl:with-param name="s" select="concat(substring-before($s,'||CHR(TO_NUMBER('27','xx'))||'&#xD;'||CHR(TO_NUMBER('27','xx'))||'),'||CHR(TO_NUMBER('27','xx'))||'\r'||CHR(TO_NUMBER('27','xx'))||',substring-after($s,'||CHR(TO_NUMBER('27','xx'))||'&#xD;'||CHR(TO_NUMBER('27','xx'))||'))"/>

196,200c197,201
< <xsl:template match="text()[not(string(number())='NaN' or
< (starts-with(.,'0' ) and . != '0' and
< not(starts-with(.,'0.' ))) or
< (starts-with(.,'-0' ) and . != '-0' and
< not(starts-with(.,'-0.' )))


<xsl:template match="text()[not(string(number())='||CHR(TO_NUMBER('27','xx'))||'NaN'||CHR(TO_NUMBER('27','xx'))||' or
(starts-with(.,'||CHR(TO_NUMBER('27','xx'))||'0'||CHR(TO_NUMBER('27','xx'))||' ) and . != '||CHR(TO_NUMBER('27','xx'))||'0'||CHR(TO_NUMBER('27','xx'))||' and
not(starts-with(.,'||CHR(TO_NUMBER('27','xx'))||'0.'||CHR(TO_NUMBER('27','xx'))||' ))) or
(starts-with(.,'||CHR(TO_NUMBER('27','xx'))||'-0'||CHR(TO_NUMBER('27','xx'))||' ) and . != '||CHR(TO_NUMBER('27','xx'))||'-0'||CHR(TO_NUMBER('27','xx'))||' and
not(starts-with(.,'||CHR(TO_NUMBER('27','xx'))||'-0.'||CHR(TO_NUMBER('27','xx'))||')))
206,207c207,208
< <xsl:template match="text()&lt;span&gt;[translate(.,'TRUE','true')='true']&lt;/span&gt;">true</xsl:template>
< <xsl:template match="text()&lt;span&gt;[translate(.,'FALSE','false')='false']&lt;/span&gt;">false</xsl:template>


<xsl:template match="text()&lt;span&gt;[translate(.,'||CHR(TO_NUMBER('27','xx'))||'TRUE'||CHR(TO_NUMBER('27','xx'))||','||CHR(TO_NUMBER('27','xx'))||'true'||CHR(TO_NUMBER('27','xx'))||')='||CHR(TO_NUMBER('27','xx'))||'true'||CHR(TO_NUMBER('27','xx'))||']&lt;/span&gt;">true</xsl:template>
<xsl:template match="text()&lt;span&gt;[translate(.,'||CHR(TO_NUMBER('27','xx'))||'FALSE'||CHR(TO_NUMBER('27','xx'))||','||CHR(TO_NUMBER('27','xx'))||'false'||CHR(TO_NUMBER('27','xx'))||')='||CHR(TO_NUMBER('27','xx'))||'false'||CHR(TO_NUMBER('27','xx'))||']&lt;/span&gt;">false</xsl:template>
231c232
< <xsl:template match="*&lt;span&gt;[count(../&lt;em&gt;[name(../&lt;/em&gt;)=name(.)])=count(../&lt;em&gt;) and count(../&lt;/em&gt;)\&gt;1]&lt;/span&gt;"></xsl:template>


<xsl:template match="*&lt;span&gt;[count(../&lt;em&gt;[name(../&lt;/em&gt;)=name(.)])=count(../&lt;em&gt;) and count(../&lt;/em&gt;)'||CHR(TO_NUMBER('26','xx'))||'gt;1]&lt;/span&gt;">
244c245
< </xsl:template>


249,250c250,253
<
< ^';



'
;
270c273
< Remarks:


Remarks:
276c279
<


280c283
<


282c285
<


288c291
<


292c295
<


295c298
<


297c300
<


299c302
<


311c314
<


314c317
< else


else
325c328
< else


else

329c332
<


339c342
< when others then raise;


when others then raise;
355,357c358