Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    England
    Posts
    15

    Unanswered: Member function error

    I am using Oracle 9i on Windows XP.
    I am trying to complete a tutorial for my Database class and have come across an error which I can't get around. I enter the following code which seems to work:

    ALTER TYPE student_type REPLACE AS OBJECT
    (FirstName varchar2(15),
    LastName varchar2(15),
    Address address_type,
    Contact contact_type,
    DateOfBirth date,
    Nationality varchar2(15),
    AttendanceMode varchar2(15),
    StudentNo varchar2(15),
    Userid varchar(15),
    FeeStatus varchar2(25),
    MEMBER FUNCTION getName RETURN varchar2,
    PRAGMA RESTRICT_REFERENCES (getName, WNDS, WNPS, RNDS, RNPS)
    )
    /

    It produces the result "Type altered."

    Then I enter the following code to implement my member function:
    CREATE TYPE BODY student_type IS
    MEMBER FUNCTION getName RETURN VARCHAR2 IS
    BEGIN
    RETURN (FirstName || '' || LastName);
    END;
    /

    (not sure if I should have the "/" at the end but thats the only way I can get it to run)

    and I recieve the following error message:
    CREATE TYPE BODY student_type IS
    *
    ERROR at line 1:
    ORA-00955: name is already used by an existing object

    I know I already have an object type named student_type but have been given the code to implement my member function by my teacher and assumed it would work.

    Any suggestions?
    Thanks in advance.
    James

  2. #2
    Join Date
    Nov 2003
    Location
    Rotterdam, Netherlands
    Posts
    127
    You should use
    CREATE OR REPLACE TYPE BODY......

    INSTEAD OF JUST

    CREATE TYPE BODY

  3. #3
    Join Date
    Nov 2003
    Location
    Bangalore, INDIA
    Posts
    333

    Thumbs up

    HI,

    Enter a unique name for the database object type or modify or drop the existing object so it can be reused.
    SATHISH .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •