By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,533 Members | 2,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,533 IT Pros & Developers. It's quick & easy.

bytea -> text

P: n/a

I need to do something like this:

select * from sms where message ilike 'foo%';

Message is a bytea field with UTF-8 content. The charset is actually not
important for me, it would be enough if it could just treat it as us ascii. The
statement does not work because postgresql can not convert bytea to text. But
this works:

select * from sms where message like 'foo%';

Seems like "like" knows how to convert bytea to text, but I can not find any
generic function that does this convertation so I can use it with ilike (or

Is there any reasonable easy way for me to do case insensitive matching on that
bytea field?


This message was sent using IMP, the Internet Messaging Program.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Baldur Norddahl <bb***************> writes:
Seems like "like" knows how to convert bytea to text,

No, it doesn't. The reason that works is there's a LIKE operator for
bytea (try "\do ~~" in psql).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.