SQL>
SQL> create or replace type employeeType is object (
2 empNo NUMBER,
3 eName VARCHAR2(10),
4 job VARCHAR2(9),
5 hireDate DATE,
6 sal NUMBER,
7 comm NUMBER,
8 member procedure p_changeName (i_newName_tx VARCHAR2),
9 member function f_getIncome_nr return VARCHAR2
10 )
11 /
SP2-0816: Type created with compilation warnings
SQL>
SQL> create or replace type body employeeType as
2 member function f_getIncome_nr return VARCHAR2 is
3 begin
4 return sal+comm;
5 end f_getIncome_nr;
6
7 member procedure p_changeName (i_newName_tx VARCHAR2) is
8 begin
9 eName:=i_newName_tx;
10 end p_changeName;
11 end;
12 /
SP2-0818: Type Body created with compilation warnings
SQL>
SQL>
SQL> declare
2 v_employeeType employeeType;
3 begin
4 v_employeeType:=employeeType(100,'TestEmp', 'JobTitle', sysdate,1000, 500);
5 v_employeeType.sal:=v_employeeType.sal+500;
6
7 DBMS_OUTPUT.put_line('Employee:'||v_employeeType.eName||' has income '||v_employeeType.f_getIncome_nr());
8 end;
9 /
Employee:TestEmp has income 2000
PL/SQL procedure successfully completed.
SQL>
SQL> drop type employeeType
2 /
Type dropped.
SQL>
SQL>
SQL>
SQL>