Tuesday, June 19, 2012

Column Names in upper case for Oracle subquery

Oracle is case-insensitive for table and column names in queries but the data dictionary records names in uppercase.

check out this example below:

select User_Number, User_Description from (
select user_id as "User_Number", User_name as "User_Description" from users_tbl);

The above query returns error as below:

ORA-00904: "USER_DESCRIPTION": invalid identifier
00904. 00000 -  "%s: invalid identifier"

Corrected query:

select USER_NUMBER, USER_DECSRIPTION from (
select user_id as "USER_NUMBER", User_name as "USER_DECSRIPTION" from users_tbl);

No comments:

Post a Comment