0

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;
Ben
  • 51,770
  • 36
  • 127
  • 149
Mr.AwesomeSauce
  • 27
  • 1
  • 3
  • 8

1 Answers1

2

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.

Ben
  • 51,770
  • 36
  • 127
  • 149
  • 1
    thanks. i love having my teacher assign us textbook that doesnt work with the DBMS he assigned us =_= – Mr.AwesomeSauce Mar 10 '14 at 20:37
  • That's no problem @Mr.AwesomeSauce :-). I would highly recommend reading [the documentation](http://docs.oracle.com/cd/E11882_01/index.htm) or something like [Tech on the Net](http://www.techonthenet.com/oracle/) if you run into problems. – Ben Mar 10 '14 at 20:38