473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Beginners problem with assigning object methods.

Hi, hope you can help,

Just starting to learn about objects-relationals and I've come across
what I hope is a little problem, when I try and make the method code,
I get told the type already exists, heres a stripped down example, I'm
sure its a terribly simple mistake:

-- Example object type [works fine]:

CREATE OR REPLACE TYPE student_type as object
(firstName varchar2(25),
MEMBER FUNCTION getName RETURN varchar2,
PRAGMA RESTRICT_REFERENCES (getName, WNDS, WNPS, RNDS, RNPS))
/

-- Example object body type:

CREATE TYPE BODY student_type IS
MEMBER FUNCTION getName RETURN VARCHAR2 IS
BEGIN
RETURN SELF.firstName;
END;
END;
/

-- Error I get is:

ERROR at line 1:
ORA-00955: name is already used by an existing object

All I want to do (for now) is just to get the info out of the object,
like

create table student of student_type;
select s.getName() from student s;

If I can get this test working then I can finally progress on, I
understand that student_type does exist, but surely (and from the
examples im reading) I need to specify where this method belongs.

Thanks,

Doobai.
Jul 19 '05 #1
1 2352
I can run your example code without errors on my system. Are you sure that
the type body has not already been declared? Change "CREATE" to "CREATE OR
REPLACE" and see if everything goes well.

--
Cheers,
Chris

___________________________________

Chris Leonard, The Database Guy
http://www.databaseguy.com

Brainbench MVP for Oracle Admin
http://www.brainbench.com

MCSE, MCDBA, OCP, CIW
___________________________________

"Doobai" <no@no.com> wrote in message
news:2m********************************@4ax.com...
Hi, hope you can help,

Just starting to learn about objects-relationals and I've come across
what I hope is a little problem, when I try and make the method code,
I get told the type already exists, heres a stripped down example, I'm
sure its a terribly simple mistake:

-- Example object type [works fine]:

CREATE OR REPLACE TYPE student_type as object
(firstName varchar2(25),
MEMBER FUNCTION getName RETURN varchar2,
PRAGMA RESTRICT_REFERENCES (getName, WNDS, WNPS, RNDS, RNPS))
/

-- Example object body type:

CREATE TYPE BODY student_type IS
MEMBER FUNCTION getName RETURN VARCHAR2 IS
BEGIN
RETURN SELF.firstName;
END;
END;
/

-- Error I get is:

ERROR at line 1:
ORA-00955: name is already used by an existing object

All I want to do (for now) is just to get the info out of the object,
like

create table student of student_type;
select s.getName() from student s;

If I can get this test working then I can finally progress on, I
understand that student_type does exist, but surely (and from the
examples im reading) I need to specify where this method belongs.

Thanks,

Doobai.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: jfj | last post by:
I don't understand. We can take a function and attach it to an object, and then call it as an instance method as long as it has at least one argument: ############# class A: pass def...
4
by: Marc Tanner | last post by:
Hello, I am currently working on a eventhandling system or something similar, and have the problem of loosing scope. I have read many interesting posts on this group and the faq article about...
8
by: Robert | last post by:
Hi, I can use "with" like this: function MyObject(message) { this.message = message; } function _MyObject_speak() {
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
4
by: Jon | last post by:
This seems strange, but maybe there's some basic concept I'm missing. When I assign one class member to another, any methods that are applied to one are applied to both variables.I can't get the...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
27
by: SamJs | last post by:
WITH (this) { a = 5 } I'm finding that this.a = 5 will come from this expression. I would have thought that the search for a would come up undefined and leave it at that. Is JavaScript...
17
by: JD | last post by:
hi, i m new to java, i want to know if there is a good and free Java IDE that i can use that'll help me, i dont care if its complicated , i just want it to be good, i tried netbeans which comes...
1
by: Doobai | last post by:
Hi, hope you can help, Just starting to learn about objects-relationals and I've come across what I hope is a little problem, when I try and make the method code, I get told the type already...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.