I have this new problem after creating the Subscriber table of Subscriber_T type and its function i cant seem to insert any value in Subscrber table. The error, i keep getting is column not allowed here. But where???
These are the scripts and an insert record.
CREATE OR REPLACE TYPE Surnames_T AS OBJECT (
Surname varchar (20)
);
/
CREATE OR REPLACE TYPE listSurnames_T
AS Varray(4) of Surnames_T;
/
CREATE OR REPLACE TYPE listTels as object(
Tel number (12)
);
/
CREATE OR REPLACE TYPE listTels_T as Varray(5) of listTels;
/
CREATE OR REPLACE TYPE ADDRESS_T AS OBJECT (
NUM number (6),
STREET varchar (20),
TOWN varchar (20)
);
/
CREATE or replace type TAddress
as table of Address_T;
/
create or replace type Subscriber_T as object(
num_s number(6),
sName varchar(30),
surname listSurnames_T,
Adds TAddress,
DateOfBirth date,
phoneNo listTels_T,
member function Age return number
);
/
create table Subscribers of Subscriber_T(
CONSTRAINT subscriber_pk primary key (num_s)
)
nested table Adds store as Tab_Adds;
/
show errors
create or replace type body Subscriber_T as
member function Age return number is
calc_age number;
dob date;
diff date;
begin
select S.dateOfBirth into dob
from Subscribers S
where deref(S.num_s) = self
diff := sysdate - dob
calc_age := to_Char(diff, 'YYYY')
return cal_age;
end;
end;
/
show errors
insert into Subscribers values (34, Chloe, listSurnames_T(Surnames_T('Dave'), Surnames_T('Camille'), Surnames_T('Jones')),
TAddress(Address_T(10, 'ave Foch', 'Ravenwood'), Address_T(30, 'rue des pole', 'England')),
'10-11-1976',
listTels_T(listTels(5839550456), listTels(6834734567)));
I'm guessing the function is raising this problem but it shows no error on compilation.