Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Query CLOB Column That Contains a Given String

Status
Not open for further replies.

YerMom

Programmer
Oct 3, 2006
127
US
I have a table with a CLOB column and I want to select all rows where the column contains
Code:
<?xml version="1.0" encoding="UTF-8"?><AddressInfo/>

How do I do this?

thanks.
 
YerMom,

For query purposes, CLOB should behave no differently from a VARCHAR2:
Code:
SQL> desc yermom
 Name                    Null?    Type
 ----------------------- -------- ----------------
 X                                CLOB

select * from yermom;

X
-------------------------------------------------------------------------------------------------
This is leading text. <?xml version="1.0" encoding="UTF-8"?><AddressInfo/> This is trailing text.
This is leading text. <?xml version="1.0" encoding="UTF-8"?><AddressInfo/> This is trailing text.
This is leading text. <?xml version="1.0" encoding="UTF-8"?><NameInfo/> This is trailing text.
This is leading text. <?xml version="1.0" encoding="UTF-8"?><NameInfo/> This is trailing text.

select count(*) from yermom where x like '%<?xml version="1.0" encoding="UTF-8"?><AddressInfo/>%';

  COUNT(*)
----------
         2
Let us know if you are having problems.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”
 
TurkBear and Santa,

Thanks for the help. I had tried something similar to Santa's sample before posting my question and got an error. I don't remember exactly what it was -- sounded like some kind of type mismatch.

In any case, Santa's query worked fine. It was slow, but that was probably because (1) the table has over 25,000 rows and (2) I'm sure that because of the potentially large size of data in a CLOB column, oracle had to spend more time searching.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top