Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use listagg for more than 7000 characters please

User_XG96WDec 22 2022 — edited Dec 22 2022

Hello ,
I am using oracle version 12c .
My code is as follows :
with employee_list as (
SELECT listagg(e1.first_name, ',' on overflow truncate) within group (order by e1.first_name) AS LISTFNAME,
WM_CONCAT (
DISTINCT
CASE
WHEN e1.family_active = 'Y'
OR e1.family_id IS NULL
THEN
e1.middle_name
ELSE
NULL
END)
AS LISTFNAME_2
,deptname
FROM employees e1
group by deptname)
SELECT CASE
WHEN e.LISTFNAME IS NOT NULL
THEN
CASE
WHEN e.LISTFNAMES_2 NOT NULL THEN e.LISTFNAME||','||e.LISTFNAMES_2
ELSE e.LISTFNAME
END
ELSE
CASE
WHEN e.LISTFNAMES_2 IS NOT NULL THEN e.LISTFNAMES_2
ELSE NULL
END
END
from departments d, employee_list e
where d.dept_name = e.deptname

------
I am getting the following error :
ORA-01489: result of string concatenation is too long
01489. 00000 - "result of string concatenation is too long"
*Cause: String concatenation result is more than the maximum size.
*Action: Make sure that the result is less than the maximum size.

Comments
Post Details
Added on Dec 22 2022
4 comments
1,193 views