问题
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