|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
probably a really simple question, but...
I'm very new to using db2, and am trying to do the following:
write a script to create a type named persontype, then a typed table named person of that type, then 2 sub-table student and employee which have extra attributes... i think the code below is somewhere close but i don't really understand what should be put in the red parts and why... can anyone shed some light? Ta CREATE TYPE PERSONTYPE AS ( NAME VARCHAR(40), BIRTHYEAR INTEGER ) REF USING INTEGER INSTANTIABLE NOT FINAL MODE DB2SQL CREATE TABLE PERSON OF PERSONTYPE (REF IS PEOPLE USER GENERATED) CREATE TYPE STUDENT UNDER PERSONTYPE AS (DEGREE_SCHEME VARCHAR(20) ) INSTANTIABLE NOT FINAL MODE DB2SQL CREATE TABLE STUDENT OF STUDENT (REF IS PERSON USER GENERATED) CREATE TYPE EMPLOYEE UNDER PERSONTYPE AS (SALARY INTEGER) INSTANTIABLE NOT FINAL MODE DB2SQL CREATE TABLE EMPLOYEE OF PERSONTYPE (REF IS EMPLOYEE USER GENERATED) |
|
#2
|
|||
|
|||
|
whats the error you get? here is a sample type in oracle! (dont know db2)
Code:
Create or replace Type Person_type as object ( Info info_type, address address_type, contact contact_type, Member function getUserId return Varchar2, Pragma Restrict_references(getUserId,wnds,wnps,rnps) ) INSTANTIABLE NOT FINAL / then you need to do this: Code:
create or replace type body Person_type IS Member function getUserId return varchar2 IS name varchar2(60); Begin name:=info.UserId ||' '|| info.FName || ' ' || info.LName; return name; End; END; / if you have more methods you put them in my first code after using same context andthen you also put them in the second code using the same thing as i done! PS> if u r wondering what i am doing here if i dont do DB2 is because i am curious to see the difference between db2/mysql/oracle! lol also i apologise if this isnt any good for you! |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > probably a really simple question, but... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|