I have written this script and now get an error that
"Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 68579, maximum: 4000)". How can I fix this?
set serveroutput on;
Declare
match_count Number :=0;
v_from NUMBER(19) :=2019030651;
CURSOR s is
(SELECT owner, table_name, column_name
FROM ALL_TAB_COLUMNS
where
owner LIKE 'SOMETHING_%'
);
begin
for t in s LOOP
begin
EXECUTE IMMEDIATE 'SELECT count(*) FROM '||t.owner || '.' || t.table_name|| ' WHERE '||t.column_name||' LIKE :1' INTO match_count USING v_from;
IF match_count > 0 THEN
dbms_output.put_line( t.table_name ||' '||t.column_name||' '||match_count );
END IF;
end;
END LOOP;
end;
Error report -
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 68579, maximum: 4000)
ORA-06512: at line 19
ORA-06512: at line 19
22835. 00000 - "Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: %s, maximum: %s)"
*Cause: An attempt was made to convert CLOB to CHAR or BLOB to RAW, where
the LOB size was bigger than the buffer limit for CHAR and RAW
types.
Note that widths are reported in characters if character length
semantics are in effect for the column, otherwise widths are
reported in bytes.
*Action: Do one of the following
1. Make the LOB smaller before performing the conversion,
for example, by using SUBSTR on CLOB
2. Use DBMS_LOB.SUBSTR to convert CLOB to CHAR or BLOB to RAW.