Low severitydata
Oracle Database Error:
ORA-01489
What does this error mean?
A string concatenation operation in Oracle produces a result that exceeds the maximum length for the data type (4000 bytes for VARCHAR2, 32767 in PL/SQL).
Common causes
- 1Pipeline builds a long SQL or JSON string via concatenation and exceeds the VARCHAR2 limit
- 2Aggregation function such as LISTAGG produces a result longer than 4000 characters
- 3Multiple text columns are concatenated together producing an oversized result
How to fix it
- 1Step 1: Use CLOB instead of VARCHAR2 for the result: `CAST(col AS CLOB) || other_col`.
- 2Step 2: For LISTAGG, use `ON OVERFLOW TRUNCATE` to limit the result: `LISTAGG(col, ',') WITHIN GROUP (ORDER BY id) ON OVERFLOW TRUNCATE`.
- 3Step 3: Limit the number of concatenated rows or add a WHERE clause to reduce the set.
- 4Step 4: Move the concatenation to the application layer where string size limits are more flexible.
- 5Step 5: Use `XMLAGG` + `XMLELEMENT` + `GETCLOBVAL` for unlimited aggregation.
Example log output
ORA-01489: result of string concatenation is too long
SQL: SELECT LISTAGG(tag, ',') WITHIN GROUP (ORDER BY id) FROM product_tags GROUP BY product_id