Search content within a bytea field

From: Damiano Bolzoni <damiano(dot)bolzoni(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Search content within a bytea field
Date: 2009-08-30 20:33:00
Message-ID: 6fb522db0908301333o3bfeb6e9l5c2ad9dd04308e18@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi all,
I'm trying to search for some content within a bytea field. My
PreparedStatement looks like this:

SELECT id FROM mytable WHERE myfield LIKE ?

Now, when I execute a

ps.setString(1, "%" + value + "%")

where 'value' is the value I want to search for, the PS becomes

SELECT id FROM mytable WHERE myfield LIKE %VALUE%

and the query clearly fails ("operator does not exist: bytea ~~
character varying"). Now, my question is....why? What am I doing
wrong?

Thanks for you help!

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sylvain Leroux 2009-08-30 21:51:51 Re: Search content within a bytea field
Previous Message Brett Henderson 2009-08-30 06:24:43 Re: Prepared Statement Query Planning