我对PL SQL世界有了新的认识......并且无法找到我的问题的答案......所以这里是:
create or replace
TYPE "A" as object{
school_category varchar(10);
}
create or replace
TYPE "B" UNDER A {
school_name varchar(10);
school_ranking INTEGER;
}
我的问题: 1.如何初始化B类对象,并初始化其父对象的属性? 2.无论如何,在创建对象时是否明确地为属性赋值?例如,我们有这样的事情:
B_obj B:= B(学校名称:="示例",school_ranking:=" 1",school_category:="小学");
先谢谢你们......
答案 0 :(得分:0)
CREATE TYPE address_typ AS OBJECT (
street VARCHAR2(30),
city VARCHAR2(20),
state CHAR(2),
postal_code VARCHAR2(6) );
/
CREATE TYPE employee_typ AS OBJECT (
employee_id NUMBER(6),
first_name VARCHAR2(20),
last_name VARCHAR2(25),
email VARCHAR2(25),
phone_number VARCHAR2(20),
hire_date DATE,
job_id VARCHAR2(10),
salary NUMBER(8,2),
commission_pct NUMBER(2,2),
manager_id NUMBER(6),
department_id NUMBER(4),
address address_typ,
MAP MEMBER FUNCTION get_idno RETURN NUMBER,
MEMBER PROCEDURE display_address ( SELF IN OUT NOCOPY employee_typ ) );
/
DECLARE
emp employee_typ; -- emp is atomically null
BEGIN
-- call the constructor for employee_typ
emp := employee_typ(315, 'Francis', 'Logan', 'FLOGAN',
'555.777.2222', '01-MAY-04', 'SA_MAN', 11000, .15, 101, 110,
address_typ('376 Mission', 'San Francisco', 'CA', '94222'));
DBMS_OUTPUT.PUT_LINE(emp.first_name || ' ' || emp.last_name); -- display details
END;
/
有关详细信息,请参阅Oracle doc:https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/objects.htm