oracle-databaseselectnclob

Oracle Select where NCLOB is Like some string


I have an Oracle table, and in this table I have a column of type NCLOB. I would like to perform a SELECT LIKE on it like so:

SELECT
*
FROM
T_WEB_TASK_IT
WHERE DBMS_LOB.substr( T_WEB_TASK_IT.ISSUE_DESCRIPTION , 32000, 1)
LIKE '%Turning on the%'

But it isn't working, I get an error saying:

String buffer too small

But I don't understand how can that be, cause I know for a fact that there aren't that many characters in that column for that particular record!


Solution

  • You can use DBMS_LOB.INSTR function to search for strings in the lob. Like this:

    SELECT *
    FROM   T_WEB_TASK_IT
    WHERE  DBMS_LOB.INSTR( T_WEB_TASK_IT.ISSUE_DESCRIPTION , 'Turning on the') > 0