Home » SQL & PL/SQL » SQL & PL/SQL » Help in Retrieving Oracle Keywords Defined Columns
Help in Retrieving Oracle Keywords Defined Columns [message #414427] Wed, 22 July 2009 02:11 Go to next message
Hemanth123
Messages: 56
Registered: April 2009
Member
Hi,

We have a Table called DETAIL in which a column with name "COMMENT" has been defined with datatype NVARCHAR2(255).

But When I am selecting the same column from the table it is throwing an error(I am using it in a procedure).

Please let me know if there is any way to select the defined column as Can not change the name of the column in the table.

Any suggestions are welcome.

Thanks,
Hemanth

[Updated on: Wed, 22 July 2009 02:13]

Report message to a moderator

Re: Help in Retrieving Oracle Keywords Defined Columns [message #414434 is a reply to message #414427] Wed, 22 July 2009 02:46 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Put the column name in quotes. (And I'm sure that you already recognise that using a name such as 'comment' is foolish at best)
Re: Help in Retrieving Oracle Keywords Defined Columns [message #414435 is a reply to message #414427] Wed, 22 July 2009 02:47 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Try with double quotes:
SQL> create table test (comment nvarchar2(255));
create table test (comment nvarchar2(255))
                   *
ERROR at line 1:
ORA-00904: : invalid identifier


SQL> create table test ("comment" nvarchar2(255));

Table created.

SQL> select comment from test;
select comment from test
       *
ERROR at line 1:
ORA-00936: missing expression


SQL> select "comment" from test;

no rows selected

SQL>

Obviously, it was a bad idea to name this column "comment".
Re: Help in Retrieving Oracle Keywords Defined Columns [message #414436 is a reply to message #414427] Wed, 22 July 2009 02:56 Go to previous message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select keyword from v$reserved_words where keyword = 'COMMENT';
KEYWORD
------------------------------
COMMENT

1 row selected.

Don't use a reserved word as an identifier.

Regards
Michel
Previous Topic: Invalid ORA-01422 Error
Next Topic: Need to schedule more than one procedure in a single job
Goto Forum:
  


Current Time: Fri Dec 02 14:16:20 CST 2016

Total time taken to generate the page: 0.07382 seconds