Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: stripping html from a clob

Re: stripping html from a clob

From: stephen O'D <stephen.odonnell_at_gmail.com>
Date: 20 Jul 2005 13:26:24 -0700
Message-ID: <1121891184.372391.149220@g43g2000cwa.googlegroups.com>


I grabbed the code for str_html off asktom which is below:-

  function str_html ( line in varchar2 ) return varchar2 is

    x       varchar2(32767) := null;
    in_html boolean         := FALSE;
    s       varchar2(1);

  begin
    if line is null then
      return line;
    end if;
    for i in 1 .. length( line ) loop
      s := substr( line, i, 1 );
      if in_html then
        if s = '>' then
          in_html := FALSE;
        end if;
      else
        if s = '<' then
          in_html := TRUE;
        end if;
      end if;
      if not in_html and s != '>' then
        x := x || s;
      end if;

    end loop;
    return x;
  end str_html;

To change this to work with a clob should be pretty easy (the following code is not tested ... )

  function str_html ( line in clob ) return clob is

    x       clob;
    in_html boolean         := FALSE;
    s       varchar2(1);

  begin
--if line is null then

    for i in 1 .. dbms_lob.getlength( line ) loop       s := dbms_lob.substr( line, 1, i ); -- dbms_lob substr's last two params

Give that a try and see how it works out. Received on Wed Jul 20 2005 - 15:26:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US