Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method for Using a Reserved Word

Status
Not open for further replies.

snwill

MIS
Jan 22, 2002
10
0
0
US
I have inherited a database with a table which includes a field named Value. I need to refer to this field name to create a View, and Oracle gives me an invalid field name error. I understand that VALUES is a Reserved Word, but is there any way to allow Oracle to accept a field name which is so close to a Reserved Word, or for that matter a Reserved Word?
Thanks,
Spiro
 

Both VALUE and VALUES are reserved keywords, at least according to the PL/SQL reference manual I have.

It is never good practice to create objects in the database using reserve words, and generally to get them to work you would need to jump through hoops. To get around using VALUES as a field name, you must always refer to the table name when using the field (select sales.values where quarter = 3). This is something you would not be able to do if creating a view from a table using a reserve word as a fieldname.

In this case you have inherited a bad (or poor choice) field name, but for the sake of good coding practices, It should be rename to include a qualifier. In this case, change the field name to reflect where the values are coming from, such as car_values, furniture_values, Bob_application_values. Of course, if you have 30,000 lines of code that uses VALUES, this may not be permitable or fesible.

 
In my Oracle 8.0.6 I can create table and view with column
name VALUE , bot not VALUES.

create table aaa (code varchar(5), value number);
Table created.

create view ddd as select code,value,empno from emp,aaa;
View created.

create table aaa (code varchar(5), values number)
*
ERROR at line 1:
ORA-00904: invalid column name

 
Try creating the view in this fashion create view viewname as select "value" value
or
create view viewname as select "value"

hope it works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top