Unix Technical Forum

LONG to clob/varchar2(4000)

This is a discussion on LONG to clob/varchar2(4000) within the Oracle Miscellaneous forums, part of the Oracle Database category; --> I know that I can cast a long to clob using to_lob() and an insert/create table but I do ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:57 AM
luke.pickett@gmail.com
 
Posts: n/a
Default LONG to clob/varchar2(4000)

I know that I can cast a long to clob using to_lob() and an
insert/create table but I do not have write access to the database only
read access. I need to search within the long for a specific word and
I am not sure how to do this. I know I am making this too hard and
their is an easy answer but I don't see it. I have a couple of examples
I have tried with no success:

select ALL_TEXT
from Long_text
where CAST(ALL_TEXT as VARCHAR2(4000)) like '%Smith%'

select ALL_TEXT
from Long_text
where contains(CAST(ALL_TEXT as VARCHAR2(4000)), 'Smith') >0

select ALL_TEXT
from Long_text
where contains(to_lob(ALL_TEXT), 'Smith') >0

..... and lots more. I have tried to create temp tables to store this
but as I cannot write to the db I also get errors(maybe missing
something there too.) Oracle version 9i.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 10:57 AM
Vladimir M. Zakharychev
 
Posts: n/a
Default Re: LONG to clob/varchar2(4000)


luke.pickett@gmail.com wrote:
> I know that I can cast a long to clob using to_lob() and an
> insert/create table but I do not have write access to the database only
> read access. I need to search within the long for a specific word and
> I am not sure how to do this. I know I am making this too hard and
> their is an easy answer but I don't see it. I have a couple of examples
> I have tried with no success:
>
> select ALL_TEXT
> from Long_text
> where CAST(ALL_TEXT as VARCHAR2(4000)) like '%Smith%'
>
> select ALL_TEXT
> from Long_text
> where contains(CAST(ALL_TEXT as VARCHAR2(4000)), 'Smith') >0
>
> select ALL_TEXT
> from Long_text
> where contains(to_lob(ALL_TEXT), 'Smith') >0
>
> .... and lots more. I have tried to create temp tables to store this
> but as I cannot write to the db I also get errors(maybe missing
> something there too.) Oracle version 9i.


Ask your DBA to create an Oracle Text index on ALL_TEXT column if there
isn't one already. Then you will be able to search in that LONG column
efficiently using CONTAINS operator:

select rowid from long_text where contains(all_text,'smith',0) > 0

Note that you don't have to cast all_text to anything for CONTAINS() to
work - all it needs is a Text index on searched column.

Hth,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:22 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com