The Oracle 12c documentation about FETCH is telling the below
If the select list contains columns with identical names and you
specify the row_limiting_clause, then an ORA-00918 error occurs. This
error occurs whether the identically named columns are in the same
table or in different tables. You can work around this issue by
specifying unique column aliases for the identically named columns.
But in Oracle Live SQL i am able to run the below Query succesfully.
(there we will have 2 columns returned in the result with same name "department_id")
select *
from hr.employees e
join hr.departments d
on (e.department_id = d.department_id)
fetch next 10 rows with ties
;
Could someone explain me if this is where we should expect the Oracle Error or it the documentation meant another scenario ?
Thanks
SD
Best Answer
Do not believe everything you read in Oracle documentation.
Try the below:
Then:
1), 3) and 4) runs successfully on
12.1.0.2
, 2) throwsORA-00918
.On
12.2.0.1
, all 4 runs successfully.The one thing to keep in mind: never rely on implicit behaviour you can not control. Use explicit, unique aliases.