INDEXING clob

In order to use CLOB datatype with CONTAINS it should be indexed as CTXSYS.CONTEXT.
Is that trye that I need to drop and recreate this index each time after new value is inserted.

I found that if index has been created as a part of table definition and insert data later "CONTAINS" doesn't work.

I tested this as
1. drop/create table with CTXSYS.CONTEXT index for CLOB datatype
2. inserted data into the table using stored procedure
3. use CONTAINS, but no row returned

After I drop and re-create index "CONTAINS" returns data

Please advise
smenaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arperumalCommented:

Try this. I think you have missed ALTER INDEX



SQL> create table ctx_demo
  2      ( id number primary key,
  3       text clob
  4*    )
  5  /

Table created.

SQL> create index search_idx
  2      on ctx_demo(text)
  3      indextype is ctxsys.context
  4  
SQL> /

Index created.

SQL> insert into ctx_demo (id, text) values (1, 'How Now Brown Cow');

1 row created.

SQL> commit;

Commit complete.

SQL> select *
  2        from ctx_demo
  3       where contains (text, 'Now') > 0
  4  
SQL> /

no rows selected

SQL> alter index search_idx
  2      rebuild parameters ( 'sync' )
  3  /

Index altered.

SQL> select *
  2        from ctx_demo
  3       where contains( text, 'Now' ) > 0
  4  /

        ID                                                                      
----------                                                                      
TEXT                                                                            
--------------------------------------------------------------------------------
         1                                                                      
How Now Brown Cow                                                              
                                                                               

SQL> insert into ctx_demo ( id, text ) values (2,'This must show');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from ctx_demo where contains(text,'must') > 0;

no rows selected

SQL> alter index search_idx
  2      rebuild parameters( 'sync' )
  3  /

Index altered.

SQL> select * from ctx_demo where contains(text,'must') > 0;

        ID                                                                      
----------                                                                      
TEXT                                                                            
--------------------------------------------------------------------------------
         2                                                                      
This must show                                                                  


Hope this will help
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.