ORA-01722:选择查询时的数字无效

时间:2017-05-09 02:30:38

标签: oracle

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

当我尝试在asp下拉列表中显示它时会导致错误

[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

2 个答案:

答案 0 :(得分:2)

在SQL中,连接运算符为||,而不是+

尝试

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

答案 1 :(得分:1)

为什么使用 + 运算符来连接值,而是使用管道运算符。

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