Manikandan Periyasamy
Manikandan Periyasamy

Reputation: 620

Getting invalid number error while using alias for combining my results in sql

select id+','+DISPLAY_TO as details from n_note where id=123456;

I am ending up with the below error msg

"ORA-01722: invalid number"

I'm using sqlplus

Upvotes: 0

Views: 743

Answers (2)

Rahul
Rahul

Reputation: 77866

Other than the wrong concatenation operator used in your query (it should be ||), you are getting this error cause; you are trying

select id+','+DISPLAY_TO 

Here, most probably id is numeric column and DISPLAY_TO is a string column; and while trying to concatenate it's trying to convert DISPLAY_TO column to integer and failing with that error.

As stated here Oracle/PLSQL: ORA-01722 Error

You executed a SQL statement that tried to convert a string to a number, but it was unsuccessful.

Upvotes: 0

strauberry
strauberry

Reputation: 4199

To concatenate strings, you have to use the concatenation operator ||:

select id || ',' || DISPLAY_TO as details from n_note where id=123456;

Upvotes: 3

Related Questions