Select out of a combined view with concatenation not working? [duplicate]

橙三吉。 提交于 2019-12-02 18:31:51

问题


I tried creating a view with two values in one column using +, and the view was created successfully, but when I try selecting all from it it gives me this error:

select *
        *
ERROR at line 1: 
ORA-01722: invalid number 

I tried researching this and the concatenation operator but to my dismay have found no help. Here is the code I used to create the view, and the select also.

CREATE VIEW CombinedNameEmployeePhoneView AS
SELECT (EMPLOYEE.LastName + ' ' + EMPLOYEE.FirstName)
AS EmployeeName, EMPLOYEE.Phone as EmployeePhone
from EMPLOYEE;

select * 
from CombinedNameEmployeePhoneView;

回答1:


The concatenation operator in Oracle is the double pipe, ||. The + is used for adding numbers together, hence the error.

The view was created successfully because Oracle doesn't evaluate the data when creating it; merely ensures that it compiles.



来源:https://stackoverflow.com/questions/22310703/select-out-of-a-combined-view-with-concatenation-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!