I am working with an Oracle database that stores HTML as a Long datatype. I would like to query the database to search for a specific string within the HTML data stored in the Long.
I tried, "select * from TABLE where COLUMN like '%form%'". This causes the following Oracle error because "like" is not supported for Long datatypes.
ORA-00932: inconsistent datatypes: expected NUMBER got LONG
You can use this example without using temp table:
DECLARE
l_var VARCHAR2(32767); -- max length
BEGIN
FOR rec IN (SELECT ID, LONG_COLUMN FROM TABLE_WITH_LONG_COLUMN) LOOP
l_var := rec.LONG_COLUMN;
IF l_var LIKE '%350%' THEN -- is there '350' string?
dbms_output.put_line('ID:' || rec.ID || ' COLUMN:' || rec.LONG_COLUMN);
END IF;
END LOOP;
END;
Of course there is a problem if LONG has more than 32K characters.