user9016406
user9016406

Reputation:

Oracle error, FROM keyword not found where expected

I am trying to figure out why I am getting this error message. I have tried revising the code in various ways and still getting an error message. Error message is listed below.

ORA-00923: FROM keyword not found where expected

 SELECT 'DATABASE' as DATABASE,
         OWNER AS SCHEMA, 
         TABLE_NAME AS TABLE, 
         COLUMN_NAME AS COLUMN
   FROM ALL_TAB_COLUMNS 
  WHERE OWNER = 'ALSCMGR' 
    AND TABLE_NAME IN ('ALSC_TRANS_NONMONETARY')
    AND UPPER(COLUMN_NAME) 

Upvotes: 0

Views: 143

Answers (1)

Littlefoot
Littlefoot

Reputation: 142705

You can't use TABLE nor COLUMN as column aliases; rename them to something else, e.g.

SQL> SELECT
  2    'DATABASE'  as DATABASE,
  3    OWNER       AS SCHEMA,
  4    TABLE_NAME  AS TABLE_n,
  5    COLUMN_NAME AS COLUMN_n
  6  FROM
  7    ALL_TAB_COLUMNS
  8  WHERE
  9      OWNER = 'ALSCMGR' AND
 10      TABLE_NAME IN('ALSC_TRANS_NONMONETARY')
 11  --and UPPER(COLUMN_NAME) ;

no rows selected

SQL>

Alternatively, enclose aliases into double quotes:

SQL> SELECT
  2    'DATABASE'  as DATABASE,
  3    OWNER       AS SCHEMA,
  4    TABLE_NAME  AS "TABLE",
  5    COLUMN_NAME AS "COLUMN"
  6  FROM
  7    ALL_TAB_COLUMNS
  8  WHERE
  9      OWNER = 'ALSCMGR' AND
 10      TABLE_NAME IN('ALSC_TRANS_NONMONETARY')
 11  --and UPPER(COLUMN_NAME) ;

no rows selected

SQL>

I've removed the last "condition" (which is invalid anyway, but didn't cause that problem).

Upvotes: 5

Related Questions