Read the two error messages displayed below carefully.
The first error message says,
ERROR at line 1:
ORA-00904: "DEPT": invalid identifier
The second error message says,
ERROR at line 1:
ORA-00904: "LOC": invalid identifier
Here are my statements:
SQL> select ename, deptno from emp;
ENAME DEPTNO
---------- ----------
SMITH 20
ALLEN 30
WARD 30
......
14 rows selected.
SQL> select ename, loc, dept from emp;
select ename, loc, dept from emp
*
ERROR at line 1:
ORA-00904: "DEPT": invalid identifier
SQL> select ename, dept, loc from emp;
select ename, dept, loc from emp
*
ERROR at line 1:
ORA-00904: "LOC": invalid identifier
Well, you appear to be trying to use two columns that don’t exist. The Oracle sql parser is apparently designed to only report one error. When faced with input that contains multiple errors, it probably just reports the first one it encounters … or maybe the last one. Since your two input SQL statements mention the incorrect names in different order, this will affect the order in which the SQL parser finds the errors.
But it doesn’t matter. Both error messages are correct.