Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: very simple question
You cannot do standard SQL statements on LONGS.
But, you could write a Plsql function to search (using function INSTR) a long for a string and then do whatever (like use SUBSTR to extract certain data).
See the following Plsql function that processes the text (a LONG) column of dba_views . Also, included first below is a sample query using this function...
Note: Both the following should run as is in version 7.1 and newer.
======Plsql Function======
CREATE OR REPLACE FUNCTION PARSE_VIEW_TEXT
(p_owner VARCHAR2, p_view_name VARCHAR2, p_substr VARCHAR2, p_substr_nbr NUMBER default null )
--
--
BEGIN
l_bef_aft_nbr := 100 ;
if p_substr_nbr is null then
l_substr_nbr := 1 ;
else
l_substr_nbr := p_substr_nbr ;
end if ;
OPEN lc_view_text_csr ;
FETCH lc_view_text_csr
INTO l_text ;
if lc_view_text_csr%NOTFOUND or l_text is null then p_view_text := '***** View Not Found *****' ; else
l_pos_in_long_nbr := instr(l_text,p_substr,1,l_substr_nbr) ; if l_pos_in_long_nbr = 0 then p_view_text := Null ; else l_temp_start_nbr := l_pos_in_long_nbr-l_bef_aft_nbr ; l_temp_length_nbr := l_bef_aft_nbr ; if l_temp_start_nbr < 0 then l_temp_start_nbr := 1 ; l_temp_length_nbr := l_pos_in_long_nbr-1 ; end if ; l_before_text := substr(l_text,l_temp_start_nbr,l_temp_length_nbr) ; l_after_text := substr(l_text,l_pos_in_long_nbr+length(p_substr),l_bef_aft_nbr) ; p_view_text := l_before_text || p_substr || l_after_text ;end if ;
CLOSE lc_view_text_csr ;
RETURN p_view_text ;
END PARSE_VIEW_TEXT ;
/
show errors function PARSE_VIEW_TEXT
"Paul Taylor" <paul.taylor_at_zen.co.uk> wrote in message news:vp1j2v417904b4nos5ak56dil63dl4v3kr_at_4ax.com...
> How do I search for something in a LONG or CLOB field? I read that > Oracle 9 allows these types to be treated like VARCHAR2. But I'm using > Oracle 8i. I want to do things like LEN and LIKE on a LONG field and > have never needed to in the past.Received on Sat Jan 18 2003 - 15:00:48 CST
![]() |
![]() |