今天 一网友碰到了这个ora 6502错误,下面还原一下
note:
wm_concat PL/SQL function that returns VARCHAR2,varchar2 max chars 4000,so When the size of the return string is greater than about 2000 characters will get an ORA-06502
anbob@ORCL> select lengthb(wm_concat(employee_id)) from employee where rownum<=995;
LENGTHB(WM_CONCAT(EMPLOYEE_ID))
-------------------------------
3998
anbob@ORCL> select lengthb(wm_concat(employee_id)) from employee where rownum<=996;
select lengthb(wm_concat(employee_id)) from employee where rownum<=996
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "WMSYS.WM_CONCAT_IMPL", line 30
我的解决方法
anbob@ORCL> l
1 create or replace function my_concat
2 return clob
3 is
4 str_res clob;
5 str varchar2(20) default ',';
6 begin
7 for x in (select employee_id from employee) loop
8 str_res:=str_res||str||to_char(x.employee_id);
9 end loop;
10 return str_res;
11* end;
anbob@ORCL> select my_concat from dual;
MY_CONCAT
--------------------------------------------------------------------------------
,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,8
8,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,1
11,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,1
31,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,1
51,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,1
.....
anbob@ORCL> select length(my_concat) from dual;
LENGTH(MY_CONCAT)
-----------------
18669复制
note:
wm_concat PL/SQL function that returns VARCHAR2,varchar2 max chars 4000,so When the size of the return string is greater than about 2000 characters will get an ORA-06502
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
741次阅读
2025-04-18 14:18:38
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
644次阅读
2025-04-15 17:24:06
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
565次阅读
2025-04-20 10:07:02
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
514次阅读
2025-04-22 00:13:51
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
510次阅读
2025-04-17 17:02:24
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
495次阅读
2025-04-22 00:20:37
一页概览:Oracle GoldenGate
甲骨文云技术
477次阅读
2025-04-30 12:17:56
火焰图--分析复杂SQL执行计划的利器
听见风的声音
436次阅读
2025-04-17 09:30:30
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
381次阅读
2025-04-15 14:48:05
OR+DBLINK的关联SQL优化思路
布衣
369次阅读
2025-05-05 19:28:36
热门文章
移除DataGuard Standby配置导致Primary启动失败
2023-08-17 21352浏览
使用dblink产生的”SELECT /*+ FULL(P) +*/ * FROM XXXXX P ” 解析
2023-06-20 20908浏览
Troubleshooting 'ORA-28041: Authentication protocol internal error' change password 12c R2 DB
2020-04-08 13703浏览
浅谈ORACLE免费数据库Oracle Database XE (Express Edition) 版
2018-10-31 7680浏览
High wait event ‘row cache mutex’ in 12cR2、19c
2020-08-14 5609浏览