Thursday, January 9, 2014

Caused by: java.sql.SQLSyntaxErrorException: ORA-00918: column ambiguously defined

Caused by: java.sql.SQLSyntaxErrorException: ORA-00918: column ambiguously defined

Problem: The problem comes from while triggering a select query. In select query the multiple tables having the same column name but if we specified with out any prefix then it will throws the column ambiguously defined.

Example: Assume it two table Student and Employee. Both tables is having id, id.

Then while fetching the recored

Select id, * from Student s, Employee e;

Solution: Add prefix to the column

Select s.id, e.id, * from Student s, Employee e;

Note: Columns must be referenced as TABLE.COLUMN or TABLE_ALIAS.COLUM .

0 comments: