ethan
ethan

Reputation: 1

ORA-01722: invalid number on select query

select id + ' - ' + name from user_table order by id

it result an error when I tried to display it on a asp dropdown list

[OleDbException (0x80040e07): ORA-01722: invalid number
ORA-01722: invalid number]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1692049
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult) +253
   System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +208
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +278
   System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +264

Upvotes: 0

Views: 800

Answers (2)

Nishesh Pratap Singh
Nishesh Pratap Singh

Reputation: 2181

Why are using + operator for concatenating values, instead use pipe operator.

select id ||' - '||name from user_table order by id

Upvotes: 1

Ray Toal
Ray Toal

Reputation: 88478

In SQL, the concatenation operator is ||, not +.

Try

select id || ' - ' || name from user_table order by id

Upvotes: 2

Related Questions