假设我有一个包含嵌套表的集合:
CREATE TYPE address_type AS OBJECT (
address_code VARCHAR2(1),
address VARCHAR2(30),
city VARCHAR2(30),
state VARCHAR2(3),
zip VARCHAR2(10));
CREATE TYPE addresses_type AS TABLE OF address_type;
-- You can see here that the person may have multiple addresses (addrs)
CREATE TYPE person_type AS OBJECT (
personID NUMBER,
name VARCHAR2(30),
birthdate DATE,
gender VARCHAR2(1),
addrs addresses_type);
CREATE TYPE people_type as TABLE OF person_type;
如果我有一个 PLSQL 块,并且我想从下表中创建并加载一个人的对象及其地址,那么最简单的方法是什么?我必须执行多个查询吗?
DECLARE
the_people people_type;
BEGIN
-- want to Query and load "the_people" with everybody in the tables below:
..
END;
表:外键是 PERSON_ID
PERSON
------
PERSON_ID
NAME
BIRTHDATE
GENDER
ADDRESSES
---------
PERSON_ID
ADDRESS_CODE
ADDRESS
CITY
STATE
ZIP