在对象类型中创建一个数组

时间:2015-12-04 12:19:30

标签: oracle plsql

我想在对象类型中创建一个数组。但我做不到?我该怎么做?

 CREATE OR REPLACE TYPE object AS OBJECT
 (
     type array1 IS VARRAY(1000) OF INTEGER,
     exAr1 array1,
     type array2 IS VARRAY(1000) OF INTEGER,   
     exAr2 array2,
 );
 /

2 个答案:

答案 0 :(得分:2)

您还需要将其他类型创建为数据库对象:

create type array1 is varray(1000) of integer;
/

create type array2 is varray(1000) of integer;   
/

create or replace type object as object
 (
     exar1 array1,
     exar2 array2
 );

当然,由于array1array2类型相同,因此您并非真正需要它们:

create type array is varray(1000) of integer;
/

create or replace type object as object
 (
     exar1 array,
     exar2 array
 );

答案 1 :(得分:1)

Hey please try to create first TABLE TYPE and then reference it while creating the OBJECT Type. Let me know if this helps

--Table type creation first
CREATE OR REPLACE TYPE NUMBER_NTT1
IS
  TABLE OF NUMBER;

CREATE OR REPLACE TYPE NUMBER_NTT
IS
  TABLE OF NUMBER;

--Object creation after that
CREATE OR REPLACE TYPE object
AS
  OBJECT
  (
    exAr1 NUMBER_NTT,
    exAr2 NUMBER_NTT1 
);