我有这个查询但是我得到了一个ORA-01489错误:ORA-01489:字符串连接的结果太长了01489. 00000 - "字符串连接的结果太长",它是否可行解析这个问题可能是设置一个系统变量吗?
SELECT "USER_PRIMARY_sector","LOGIN","FIRST_NAME","LAST_NAME","sector_ROLE"
FROM (
SELECT user_primary_sector,login, first_name, last_name,
LTRIM(MAX(SYS_CONNECT_BY_PATH(rights,' / '))
KEEP (DENSE_RANK LAST ORDER BY curr),' / ') AS sector_ROLE
FROM
(SELECT login,
first_name,
last_name,
user_primary_sector,
rights,
ROW_NUMBER() OVER (PARTITION BY login ORDER BY rights) AS curr,
ROW_NUMBER() OVER (PARTITION BY login ORDER BY rights) -1 AS prev
FROM (select member0_.login, member0_.first_name first_name, sector2.sector_name user_primary_sector, member0_.last_name last_name,
CONCAT(CONCAT(sector.sector_name, ' - '), role3_.role_name) rights
from
TLC_DEVICES.t_member member0_
inner join TLC_DEVICES.t_user member0_1_ on member0_.member_id=member0_1_.user_id
inner join TLC_DEVICES.t_playable_role playedrole1_ on member0_.member_id=playedrole1_.user_id
inner join TLC_DEVICES.t_sector_role sectorrole2_ on playedrole1_.sector_role_id=sectorrole2_.sector_role_id
inner join TLC_DEVICES.t_role role3_ on sectorrole2_.role_id=role3_.role_id
inner join TLC_DEVICES.t_sector sector on sectorrole2_.sector_id=sector.sector_id
inner join TLC_DEVICES.t_sector sector2 on sector2.sector_id=member0_1_.primary_sector_id
where current_date between playedrole1_.start_date and playedrole1_.end_date
order by sector.sector_name
))
GROUP BY login, first_name, last_name, user_primary_sector
CONNECT BY prev = PRIOR curr AND login = PRIOR login
START WITH curr = 1
)
ORDER BY user_PRIMARY_sector, FIRST_NAME, LAST_NAME;
答案 0 :(得分:1)
一种选择是将MAX_STRING_SIZE
系统变量设置为EXTENDED
。
来自Oracle documentation:
具有最大长度字节或字符的可变长度字符串。您必须为VARCHAR2指定大小。最小大小为1个字节或1个字符。最大尺寸为:
32767字节或字符,如果MAX_STRING_SIZE = EXTENDED
,则为4000个字节或字符
如果MAX_STRING_SIZE = STANDARD
因此,如果您的MAX_STRING_SIZE
当前设置为STANDARD
,那么如果您的连接字符串超过4000个字节或字符,则会出现ORA-01489
错误。您可以通过以下方式进行更改:
ALTER SYSTEM SET MAX_STRING_SIZE = EXTENDED;
如果您的MAX_STRING_SIZE
已设置为EXTENDED
,那么您必须找到另一种方法来处理这么长的字符串。