I have a table which contains a field of type LONG. It can contain large blocks of text. I can extract data from this field as follows:
SELECT
NOTES.NOTE_TEXT
FROM
NOTES
WHERE
NOTES.ID = 1
The problem, however, is that I am unable to search for text within the field. If I try the following:
SELECT
NOTES.NOTE_TEXT
FROM
NOTES
WHERE
NOTES.NOTE_TEXT LIKE '%hello%'
... then I get an error: "Exception: DBD, ORA-00932: Inconsistent datatypes: expected NUMBER got LONG".
Of course, I Googled this problem to find many articles about how LONG is very limited, and that you could not search text within it. As to a solution, in several places it was suggested that the LONG could be converted to another data type. CAST AS CLOB was suggested.
I tried:
WHERE
CAST(NOTES.NOTE_TEXT AS CLOB) LIKE '%hello%'
... however this also returned an error.
I also saw some other more complex solutions involving creating functions in PL/SQL. However I do not have access to this. I am using the "Business Objects" application, which is solely a reporting tool for a read-only database. I have no access to create tables or any other kind of write operation.
(Note: the above paragraph explains why the solutions elsewhere on SO do not answer my question, as they require write access to the database. I did not find any other similar question asking exactly what I need, which is to be able to do it in a read-only query.)
Does anyone know of a way in which I can convert LONG to something usable, within a read-only query in Oracle? Thanks.