簡體   English   中英

Oracle 數據庫 PL/SQL 是否支持遞歸對象? 一個 object 在嚴格的分層樹中包含相同類型的數組/表

[英]Does Oracle Database PL/SQL support recursive objects? an object the includes array/table of same type in a strict hierarchical tree

在 Object-Relational Developer's Guide 中,我發現引用了不同的從屬/嵌入類型 - 例如,部門包括地址。 該文檔還包括解決循環引用的部分,但同樣是在不同類型的對象之間。 我正在尋找 object 來引用自己。

create or replace type a_obj is object (myself varchar2(10), parent      number, children number);
/
create or replace type c_obj is table of ref a_obj;
/
create or replace type a_obj is object (myself varchar2(10), parent a_obj, children c_obj);
/
Type A_OBJ compiled


Type C_OBJ compiled


Error starting at line : 12 in command -
create or replace type a_obj is object (myself varchar2(10), parent a_obj, children c_obj);
Error report -
ORA-02303: cannot drop or replace a type with type or table dependents
02303. 00000 -  "cannot drop or replace a type with type or table dependents"
*Cause:    An attempt was made to drop or replace a type that has
           type or table dependents.
*Action:   For DROP TYPE, drop all type(s) and table(s) depending on the
           type and then retry the operation, or use the FORCE option.
           For CREATE TYPE, drop all type(s) and table(s) depending on the
           type and then retry the operation, or drop all table(s) depending
           on the type and retry with the FORCE option.

前向聲明類型並將父級設置為REF類型:

create type a_obj;
/

create type c_obj is table of ref a_obj;
/

create or replace type a_obj is object (
  myself   varchar2(10),
  parent   REF a_obj,
  children c_obj
);
/

db<> 在這里擺弄

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM