I want to use STRAGG function in this env.: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production, PL/SQL Release 11.2.0.4.0 - Production, CORE 11.2.0.4.0 Production, TNS for Linux: Version 11.2.0.4.0 - Production, NLSRTL Version 11.2.0.4.0 - Production:
I have a view called V_USER_ROLE_DESC
LOGIN DESC
joanet BS in ANDROID.C.3
joanet DOB in ANDROID.C.3
joanet DO in ANDROID.C.3
joanet BS in ANDROID.C.4
joanet UA in ANDROID.C.4
joanet OV in ANDROID.C.4
joanet OI in ANDROID.C.4
joanet DO in ANDROID.C.4
joanet DHoU in ANDROID.C.4
joanet AOP in ANDROID.C.4
Executin this query
select
login ,
sys.STRAGG( UNIT_ROLE_DESC || ' - ' ) as string
from
V_USER_ROLE_DESC
where login = 'joanet'
group by
login
;
This is the result:
joanet BS in ANDROID.C.3 - DOB in ANDROID.C.3 - DO in ANDROID.C.3 - BS in ANDROID.C.4 - UA in ANDROID.C.4 - OV in ANDROID.C.4 - OI in ANDROID.C.4 - DO in ANDROID.C.4 - DHoU in ANDROID.C.4 - AOP in ANDROID.C.4 -
But without the where clause ...
select
login ,
sys.STRAGG( UNIT_ROLE_DESC || ' - ' ) as string
from
V_USER_ROLE_DESC
--where login = 'joanet'
group by
login
;
this is the result:
...
colau DOB in ANDROID.D.2 -
joanet DOB in ANDROID.D.2 -
sisa DOB in ANDROID.D.2 -
...
Using
SELECT login ,listagg(unit_role_desc,' - ') WITHIN GROUP (ORDER BY unit_role_desc) AS STRING FROM v_user_role_desc WHERE 1=1 GROUP BY LOGIN;
I have this error
ORA-01489: result of string concatenation is too long