can you please explain why the error ORA-00918 is generated while executing this query
INSERT INTO CLG_TEST_2 (CLG_TEST_2.record_id, CLG_TEST_2.chain_id,
CLG_TEST_2.chain_n,
CLG_TEST_2.contact_info)
select * from (
SELECT 1, 1, 0, '2222' from dual UNION ALL
SELECT 2, 2, 0, '4444' from dual UNION ALL
SELECT 3, 3, 0, '6666' from dual
)
Error at line 1 ORA-00918: column ambiguously defined
Script Terminated on line 2.
The issue is in the fact that you are using a
select *over a query without giving aliases to the columns; this will work:However, you can simplify your code:
Something more about the reason of the error.
Your code:
Slightly different:
What's different?
In the first row, I changed
The reason:
Here you have two columns with the same alias
'1', and this is confusing for the externalselect *.Also, a direct-path insert is something different