Wednesday, November 6, 2024

ORA-01489: result of string concatenation is too long

 

ORA-01489: result of string concatenation is too long

 SELECT '' ID,

        RP.GRANTEE AS USERNAME,
       LISTAGG (rp.granted_role || '-' || D.Name || '-' || P.NAME, ',') WITHIN GROUP (ORDER BY grantee) As ROLES_MEMBERSHIP,
       U.ACCOUNT_STATUS AS STATUS
    FROM CDB_ROLE_PRIVS RP,
         V$DATABASE D,
         V$PDBS P,
         CDB_USERS U
   WHERE RP.CON_ID = P.CON_ID
         AND RP.GRANTEE(+) = U.USERNAME
         AND U.CON_ID = P.CON_ID
         AND U.CON_ID >= 3
GROUP BY RP.GRANTEE,
         U.ACCOUNT_STATUS
 
 
ORA-12801: error signaled in parallel query server P007
ORA-01489: result of string concatenation is too long      

This error message is almost auto-explicative, it is because the the return of listagg function is Varchar and it has a limit of 4000 characters.

From 12.2 onwards you can use, if it is applicable for your case, the parameter to truncate the results with the clause ON OVERFLOW TRUNCATE, for our usage this solution can’t be applied, because we need to deliver the whole data to auditor requested. Just an example how to use it.

LISTAGG(NameOfYourColunm, ‘,’ ON OVERFLOW TRUNCATE)

 SELECT '' ID,
       RP.GRANTEE AS USERNAME,
       LISTAGG (rp.granted_role || '-' || D.Name || '-' || P.NAME, ',' ON OVERFLOW TRUNCATE) WITHIN GROUP (ORDER BY grantee) As ROLES_MEMBERSHIP,
       U.ACCOUNT_STATUS AS STATUS
    FROM CDB_ROLE_PRIVS RP,
         V$DATABASE D,
         V$PDBS P,
         CDB_USERS U
   WHERE RP.CON_ID = P.CON_ID
         AND RP.GRANTEE(+) = U.USERNAME
         AND U.CON_ID = P.CON_ID
         AND U.CON_ID >= 3
GROUP BY RP.GRANTEE,
         U.ACCOUNT_STATUS
         U.ACCOUNT_STATUS;

No comments:

Post a Comment

EBS : Package Development Process

====================== Package Specification ================================== CREATE OR REPLACE PACKAGE xx_emp_package IS     PROCEDURE lo...