oracle - Oracle 自依赖类型声明
问题描述
我想在 Oracle 中创建一个自定义类型,如下所示。任何人都可以告诉我如何实现这一点。
CREATE OR REPLACE TYPE Items_Type FORCE IS OBJECT ( "S.No" VARCHAR2(500) NULL , sub_list "Items_table" NULL ) NOT FINAL;
CREATE OR REPLACE TYPE Items_table IS TABLE OF REF Items_Type;
解决方案
好吧,您可以再次重复第CREATE OR REPLACE TYPE
一次,因为第一次执行时它会失败。看一看:
SQL> -- statement A
SQL> create or replace type items_type force is object
2 (sno varchar2(500) null ,
3 sub_list items_table null
4 ) not final;
5 /
Warning: Type created with compilation errors.
SQL> show err
Errors for TYPE ITEMS_TYPE:
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
3/13 PLS-00201: identifier 'ITEMS_TABLE' must be declared
SQL>
SQL> -- statement B
SQL> create or replace type items_table is table of ref items_type;
2 /
Type created.
SQL> -- statement A, repeated
SQL> create or replace type items_type force is object
2 (sno varchar2(500) null ,
3 sub_list items_table null
4 ) not final;
5 /
Type created.
SQL>
推荐阅读
- database - Oracle-DB:会话连接/断开的 CPU 成本是多少
- ios - AppClip 的多个物理位置
- pyiron - 通过 SLURM 计算期间用户定义的作业类型不可用
- r - R 版本 4 的个人包中的 UseMethod 错误
- python - 瓶子和多个请求
- python - 打包python资源(Manifest.in vs package_data vs data_files)
- flutter - 在小部件加载颤动时触发动画
- excel - VBA数字格式化Excel中的公式
- ansible - Ansible - 并行运行两个任务
- css - 无法将材料 ui 数据表列(表头)编辑到文本中心对齐(React)