I am working on the query below:
select ip.intake_id,
ip.estimated_years,
ip.gender_code,
LISTAGG(ip.race_code, ',') WITHIN GROUP (ORDER BY ip.race_code) as race_code,
eth.ethnicity_code,
i.living_arrangements,
p.dep_actv_military_flag,
LISTAGG(ale.allegation_super_type_code) WITHIN GROUP (ORDER BY ale.allegation_super_type_code) as maltreatment_type_code,
LISTAGG(ale.initial_report_disp_code) WITHIN GROUP (ORDER BY ale.initial_report_disp_code) as maltreatment_dispo_lvl,
ip.deceased_flag,
LISTAGG(ch.characteristic_code, ',') WITHIN GROUP (ORDER BY ch.characteristic_code) as chara_codes,
LISTAGG(ich.intake_characteristic_code, ',') WITHIN GROUP (ORDER BY ich.intake_characteristic_code) as intake_chara_codes,
pe.removed_date,cm.petition_submitted_flag,cm.created_date,atr.person_id
from intake i inner join intake_participant ip on i.intake_id = ip.intake_id
left outer join reporter r ON i.intake_id=r.intake_id
left outer join ethnicity eth on eth.person_id = ip.person_id
left outer join person p on p.person_id = ip.person_id
left outer join allegation ale on ale.intake_id = i.intake_id
left outer join characteristic ch on ch.person_id = ip.person_id
left outer join intake_characteristic ich on ich.intake_id = i.intake_id
left outer join placement_episode pe on pe.child_id = ip.person_id
left outer join complaint cm on cm.petitioner_id = ip.person_id
left outer join attorney atr on atr.person_id = ip.person_id
left outer join intake_participant_role apr on apr.intake_participant_id = ip.intake_participant_id
group by ip.intake_id,ip.estimated_years,ip.gender_code,eth.ethnicity_code,i.living_arrangements,p.dep_actv_military_flag,
ip.deceased_flag,pe.removed_date,cm.petition_submitted_flag,cm.created_date,atr.person_id
when I am running this query I am getting following error message:
Error report:
SQL 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.
But when I remove the line :
left outer join reporter r ON i.intake_id=r.intake_id
from my query then it executes without any error message. The working query is given below:
select ip.intake_id,
ip.estimated_years,
ip.gender_code,
LISTAGG(ip.race_code, ',') WITHIN GROUP (ORDER BY ip.race_code) as race_code,
eth.ethnicity_code,
i.living_arrangements,
p.dep_actv_military_flag,
LISTAGG(ale.allegation_super_type_code) WITHIN GROUP (ORDER BY ale.allegation_super_type_code) as maltreatment_type_code,
LISTAGG(ale.initial_report_disp_code) WITHIN GROUP (ORDER BY ale.initial_report_disp_code) as maltreatment_dispo_lvl,
ip.deceased_flag,
LISTAGG(ch.characteristic_code, ',') WITHIN GROUP (ORDER BY ch.characteristic_code) as chara_codes,
LISTAGG(ich.intake_characteristic_code, ',') WITHIN GROUP (ORDER BY ich.intake_characteristic_code) as intake_chara_codes,
pe.removed_date,cm.petition_submitted_flag,cm.created_date,atr.person_id
from intake i inner join intake_participant ip on i.intake_id = ip.intake_id
left outer join ethnicity eth on eth.person_id = ip.person_id
left outer join person p on p.person_id = ip.person_id
left outer join allegation ale on ale.intake_id = i.intake_id
left outer join characteristic ch on ch.person_id = ip.person_id
left outer join intake_characteristic ich on ich.intake_id = i.intake_id
left outer join placement_episode pe on pe.child_id = ip.person_id
left outer join complaint cm on cm.petitioner_id = ip.person_id
left outer join attorney atr on atr.person_id = ip.person_id
left outer join intake_participant_role apr on ipr.intake_participant_id = ip.intake_participant_id
group by ip.intake_id,ip.estimated_years,ip.gender_code,eth.ethnicity_code,i.living_arrangements,p.dep_actv_military_flag,
ip.deceased_flag,pe.removed_date,cm.petition_submitted_flag,cm.created_date,atr.person_id
I am not sure why this error occured. Can someone help me to figure out the problem? I got same questions from these links link1 and link2, but I didn't get the solution to my question from these links.