Skip to content
Advertisement

ORA-06502: PL/SQL: numeric or value error when concatenating

I am getting error as numeric or value error

Advertisement

Answer

The problem is with operator precedence:

Oracle evaluates operators with equal precedence from left to right within an expression.

… and as the table shows + and || have equal precedence. So in this statement:

this is interpreted as 'sum = '|| a which gives you a string, then <result string> + b, and string + number will cause the error you see if the string cannot be implicitly converted to a number – and 'sum = 1' can’t be.

You can add parentheses to override the default precedence:

db<>fiddle

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement