Home > Ask the Oracle Experts > Database Design and Architecture Questions & Answers > ORA-00904 error on select statement
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

ORA-00904 error on select statement

Brian Peasland EXPERT RESPONSE FROM: Brian Peasland

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 21 April 2006

I am working in JDEVELOPER using JDBC. This program is working with objects. I am getting this error on a SQL statement: "java.sql.SQLException: ORA-00904: "R": invalid identifier." The select statement is:

      SELECT VALUE(r)  
      FROM Rectangles r

I do not understand why I am getting an error on the select. How do I fix this? It seems like object r is not connected to anything somehow. Thanks for your help.

I have provided the supporting documentation below. The create of the objects and tables are as follows:

CREATE TYPE point_type AS OBJECT (
x NUMBER,
y NUMBER);
/

CREATE TABLE circles (
 radius   NUMBER,
 center   point_type);
/

CREATE TABLE bloom_data OF point_type;
/

INSERT INTO bloom_data values(2,3);

INSERT INTO bloom_data values(3,15);

INSERT INTO circles values
 (3,point_type(5,5));
/

CREATE TYPE rectangle_type AS OBJECT (
 top_left point_type,
 width    NUMBER,
 height   NUMBER,
 MAP MEMBER FUNCTION getarea RETURN NUMBER, MEMBER FUNCTION CONTAINS(pt IN point_type) RETURN NUMBER); /

CREATE OR REPLACE TYPE BODY rectangle_type AS
  MAP MEMBER FUNCTION getarea RETURN NUMBER AS
    BEGIN
     RETURN width * height;
    END;
  MEMBER FUNCTION CONTAINS
   (pt IN point_type) RETURN NUMBER AS 
        is_inside NUMBER := 0;
     BEGIN
       IF (pt.x > top_left.x
           AND pt.x < top_left.x + width
           AND pt.y > top_left.y
           AND pt.y < top_left.y + height)
         THEN
           is_inside := 1;
       END IF;
            RETURN is_inside;
     END;
END;
/

CREATE TABLE rectangles (
  label VARCHAR2(25),
  rectangle rectangle_type);
/

INSERT INTO rectangles VALUES ('ONE',
     rectangle_type(point_type(10,50),40,20));
/

INSERT INTO rectangles VALUES ('TWO',
     rectangle_type(point_type(0,0),10,10));
/

>
EXPERT RESPONSE

Why not just do the following:

SELECT * FROM rectangles;
You do not need the VALUE function here. If you created your table as an object table, then you could use the VALUE function. To do that, your table creation would look similar to the following:
  • Create a type to hold the entire row's values:
    CREATE rectangle_type AS OBJECT( label VARCHAR2(25), rectangle rectangle_type);
    
  • Create the object table:
    CREATE TABLE rectangle OF rectangle_type;
    

An object table is a table with only one column, the object type. From this, the VALUE function can be properly used as you have written it.

On that note, if you are writing tables for points, lines and polygons, why not use Oracle Spatial? It looks to me like you're reinventing the wheel.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Database Design and Architecture
Should we worry about Oracle memory leaks on Windows?
How to disable Oracle constraints and triggers during an import in 10g
How to delete a partition on the F: drive with Oracle on Windows
What could be causing an SQL count 0 with a successful Oracle import?
What is a staging table, and how is the staging concept used in Oracle?
Tips for how to size an Oracle server
Oracle error 942 when exporting a schema
Do DDL statements roll back, and why?
Increasing Oracle storage capacity by moving to a new storage with minimum downtime
Using Undo Tablespaces vs. rollback segments in Oracle 9i, 10g

Oracle database design
Oracle database in the cloud floated at Harvard lab
Oracle OpenWorld 2008 Special Report
Weighing remote database administration pros and cons takes care
Oracle Database 11g makes waves at Burlington Coat Factory
How to create a database link in Oracle
Data modeling tools no substitute for hard work
How do I do that in Oracle?
The Oracle Database user's guide to Oracle OpenWorld 2007
Oracle OpenWorld 2007 Special Report
How many redo log files?

Oracle error messages
ORA-12560 error with Oracle 10g Instant Client
Unable to view Oracle tables in NetBeans
IMP-00017 error message with Oracle import
Can't open database after failed backup export
Query on dblink returning ORA-12545 error
RMAN not working at command prompt
Unique constraint violations, "parent key not found" errors
Insufficient privileges error when creating stored procedure
IMP-00010 error with import from 10g to 9i
ORA-12801 error while loading seed data

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
extent  (SearchOracle.com)
field  (SearchOracle.com)
flexfield  (SearchOracle.com)
foreign key  (SearchOracle.com)
quad tree  (SearchOracle.com)
record  (SearchOracle.com)
row  (SearchOracle.com)
splay tree  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts