范围的无效标识符错误

Invalid Identifier error for scope

我创建了 customer_ty 对象,其中包含一个名为 "deposits" 的嵌套 table。

CREATE TYPE deposit_ty as object(
depNo number,
depCategory ref depcategory_ty,
amount number,
period number
)
/

此 'depCategory' 在另一个 table 中引用 depcategory_ty 称为 'depcategory_tbl'。

CREATE TYPE deposit_ntty as table of depcategory_ty
/

CREATE TYPE address_ty as varray(3) of varchar2(20)
/

CREATE TYPE customer_ty as object(
custId varchar2(4),
custName varchar2(10),
address address_ty,
dob date,
deposits deposit_ntty
)
/

CREATE TABLE customer_tbl of customer_ty(
custId primary key)
nested table deposits store as cli_deposit_tbl
/

alter table cli_deposit_tbl
add scope for (depCategory) is depcategory_tbl
/

当我尝试为 table 添加范围时出现问题。它说;

add scope for (depCategory) is depcategory_tbl
               *
ERROR at line 2:
ORA-0094:"DEPCATEGORY":Inavalid Identifier

所有标识符都是正确的。这有什么问题吗?

您似乎错误地定义了 deposit_ntty,意思是:

CREATE TYPE deposit_ntty as table of deposit_ty
/

有了这个改变,你的改变现在得到:

alter table cli_deposit_tbl
add scope for (depCategory) is depcategory_tbl
/

ORA-22892: scoped table "DEPCATEGORY_TBL" does not exist in schema "PUBLIC"

您可能已经有了,但没有显示;有了它,改变就可以了:

CREATE TABLE depcategory_tbl of depcategory_ty;

Table DEPCATEGORY_TBL created.

alter table cli_deposit_tbl
add scope for (depCategory) is depcategory_tbl
/

Table CLI_DEPOSIT_TBL altered.