Home > Ask the Oracle Database / Applications Experts > Questions & Answers > Error viewing records in table that has abstract column datatype
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Error viewing records in table that has abstract column datatype

Brian Peasland EXPERT RESPONSE FROM: Brian Peasland

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 23 December 2002
I tried to view records in an table that has one of its columns with an abstract datatype. I created the following type:
  create or replace type marks_ty as object 
  (m1 number(3), 
  m2 number(3), 
  m3 number(3), 
  member function totmarks(m1 in number,m2 in 
 number,m3 in number) 
  return number); 
  / 
Then I created type body as follows:
 
create or replace type body marks_ty as 
 member function totmarks(m1  number,m2  number,m3 
 number) 
 return number is 
 begin 
 return (m1+m2+m3); 
 end; 
 end; 
 / 
Then I created the following table:
 
 
  create table stdmarks 
  ( student_id number(4), 
  marks marks_ty); 
 
Then I inserted a couple of records. After that I issued the following statement:
 
 select marks.totmarks(marks.m1,marks.m2,marks.m3) 
 from stdmarks; 
But I get the following error:
  
 select marks.totmarks(marks.m1,marks.m2,marks.m3) 
 from stdmarks 
               * 
 ERROR at line 1: 
 ORA-00904: invalid column name 
 
Please help me. I tried the same in Oracle 8i, as well as 9i enterprise edition.

>

One of the lesser knowns facts about your operation is that you need to alias the table name, and use that alias when calling the member function. So change your query to the following:

SELECT s.marks.totmarks(marks.m1,marks.m2,marks.m3) 
FROM stdmarks s; 

For More Information


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



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



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

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




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