471,573 Members | 1,121 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,573 software developers and data experts.

bytea -> text

Hi,

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
regexp).

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

Thanks,

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

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

Nov 12 '05 #1
1 6290
Baldur Norddahl <bb***************@clansoft.dk> 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?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mPath Records | last post: by
1 post views Thread by Steve | last post: by
4 posts views Thread by Morten Goodwin Olsen | last post: by
reply views Thread by Alvar Freude | last post: by
7 posts views Thread by Dennis Gearon | last post: by
reply views Thread by Peter Wang | last post: by
reply views Thread by Oliver Nolden | last post: by
4 posts views Thread by Együd Csaba | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.