Buffer too small for CLOB to CHAR or BLOB to RAW conversion

血红的双手。 提交于 2019-12-13 04:45:12

问题


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.

回答1:


Is it sufficient for you to just query "NUMBER" data types?

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   data_type = 'NUMBER' and
            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;


来源:https://stackoverflow.com/questions/56129728/buffer-too-small-for-clob-to-char-or-blob-to-raw-conversion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!