If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Member function error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-03, 14:37
donnie_darko donnie_darko is offline
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 15
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
Reply With Quote
  #2 (permalink)  
Old 11-20-03, 07:44
shelva shelva is offline
Registered User
 
Join Date: Nov 2003
Location: Rotterdam, Netherlands
Posts: 127
You should use
CREATE OR REPLACE TYPE BODY......

INSTEAD OF JUST

CREATE TYPE BODY
Reply With Quote
  #3 (permalink)  
Old 11-20-03, 07:54
satish_ct satish_ct is offline
Registered User
 
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 .
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On