Maybe you can use the (built-in) REPLACE function. Example (tested w/ Oracle 11g, see dbfiddle):
Table for testing
create table myclobs ( col clob ) ;
insert into myclobs ( col )
values ( '<b>Hello world</b><script>window.alert(''Hello world'')</script>');
select * from myclobs ;
-- result
COL
<b>Hello world</b><script>window.alert('Hello world')</script>
Query
select
replace(
replace( col, '</script>','</script>' )
, '<script>','<script>'
) as scripttagsreplaced
from myclobs ;
-- result
SCRIPTTAGSREPLACED
<b>Hello world</b><script>window.alert('Hello world')</script>
( The "inner" REPLACE converts the end tags, and the "outer" REPLACE converts the start tags. ) If this works for you, and you still want to write your own function, just compile the following:
-- rst: Replace the Script Tags
create or replace function rst( theclob clob )
return clob
is
begin
return replace(
replace( theclob, '</script>','</script>' )
, '<script>','<script>'
) ;
end ;
/
With this in place, you can SELECT ... as follows:
select rst( col ) from myclobs ;