[英]Strange ORA-06502: PL/SQL: numeric or value error
I'm looping through the table definitions in a database and extracting the DDL in order to be able to create 'golden data' sets of table duplicates for software testing purposes. 我在数据库中遍历表定义并提取DDL,以便能够为软件测试目的创建表重复项的“黄金数据”集。 I've got the below code which extracts the DDL just fine up to one table where it throws a ORA-06502 error.
我有以下代码,它提取的DDL恰好达到一张表,并在其中引发ORA-06502错误。 The thing is, I've defined the variable that the DDL is being returned to as a CLOB, which should be big enough.
问题是,我已经定义了将DDL作为CLOB返回到的变量,该变量应该足够大。 Here's the code:
这是代码:
create or replace
procedure gettabledescription as
current_date_time varchar2(32);
sql_statement varchar2(200);
ddl_return clob;
new_ddl clob;
BEGIN
DBMS_OUTPUT.ENABLE;
current_date_time:= to_char(sysdate,'MM/DD/YYYY - HH24:MI:SS');
dbms_output.put_line(current_date_time);
for cursor_rec in (select * from user_objects where object_type='TABLE' and object_name not like 'TM%' and object_name not like 'TZ_%' and object_name not like 'EXT_%' and object_name not like 'RPT_%' and object_name not like 'ETL_%') loop
sql_statement := 'select dbms_metadata.get_ddl(''TABLE'',' || '''' || cursor_rec.object_name || '''' || ') from dual';
execute immediate sql_statement into ddl_return;
**error thrown here** new_ddl := replace(ddl_return,TO_CHAR(cursor_rec.object_name),'QA_' || TO_CHAR(cursor_rec.object_name));
dbms_output.put_line(new_ddl);
end loop;
END GETTABLEDESCRIPTION;
I don't understand why I'm getting that error. 我不明白为什么会收到该错误。
On Oracle 10gR2, When I call DBMS_OUTPUT.PUT_LINE with a varchar2 or clob longer than 8191 bytes, I receive an ORA-06502 error. 在Oracle 10gR2上,当我使用长度超过8191字节的varchar2或clob调用DBMS_OUTPUT.PUT_LINE时,会收到ORA-06502错误。 The solution would be to loop through the clob, pulling out lines and calling put_line once for each.
解决方案是遍历Clob,拔出行并为每个调用一次put_line。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.