Re: Beginners problem with assigning object methods.

From: Chris Leonard <s_p_a_m_chris_at_hotmail.com>
Date: Mon, 1 Dec 2003 09:00:42 -0600
Message-ID: <uIIyb.6$k36.18134_at_news.uswest.net>


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_at_no.com> wrote in message
news:2mrjsv81chsuvpp058rpp64d4o1mkri9cr_at_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.
Received on Mon Dec 01 2003 - 16:00:42 CET

Original text of this message