【问题标题】:Buffer too small for CLOB to CHAR or BLOB to RAW conversion缓冲区太小,无法进行 CLOB 到 CHAR 或 BLOB 到 RAW 转换
【发布时间】:2019-10-01 10:33:41
【问题描述】:

我已经写了这个脚本,现在得到一个错误

“对于 CLOB 到 CHAR 或 BLOB 到 RAW 转换的缓冲区太小(实际:68579,最大值:4000)”。 我该如何解决这个问题?


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.

【问题讨论】:

    标签: oracle plsql oracle11g sqlplus


    【解决方案1】:

    仅查询“NUMBER”个数据类型就足够了吗?

    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;
    

    【讨论】:

      猜你喜欢
      • 2014-10-20
      • 1970-01-01
      • 2015-10-21
      • 2016-03-09
      • 1970-01-01
      • 2016-09-22
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      相关资源
      最近更新 更多