范围的标识符错误无效

时间:2016-03-22 15:17:10

标签: sql oracle oop ordbms

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

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

这个' depCategory'引用另一个名为' depcategory_tbl'的表中的depcategory_ty。

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
/

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

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

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

1 个答案:

答案 0 :(得分:2)

您似乎错误地定义了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.