我已经编写了此脚本,现在出现错误
“对于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.
答案 0 :(得分:0)
仅查询“ 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;