1

当我尝试在下表中插入记录时,出现错误“ora-03001:未实现的功能”。我已经搜索了一夜,仍然没有运气。我使用的是Oracle10g 速成版。

create or replace type MajorsType As varray(20) of varchar2(10);

create or replace type studenttype as object (
stuID varchar2(5),
lastName varchar2(15),
firstName varchar2(12),
majors MajorsType)
INSTANTIABLE
NOT FINAL;

create table Student of StudentType (
constraint student_stuID_pk PRIMARY KEY(stuID));

INSERT INTO student values StudentType ('S999', 'Smith', 'John', MajorsType('Math', 'Accounting'));
4

1 回答 1

3

这是一个简单的语法错误:VALUES 子句要求所有内容都用括号括起来:

SQL> INSERT INTO student
  2  values ( StudentType ('S999', 'Smith', 'John', MajorsType('Math', 'Accounting')))
  3  /

1 row created.

SQL>

这适用于我们是否传递多个标量值或单个类型。


不适用的一种情况是使用 RECORD 类型在 PL/SQL 中插入。这与您的情况无关,但我提到它是为了完整性。

插入一个 RECORD 变量看起来像这样

declare
    r23 t23%rowtype;  -- record declaration
begin
    r23.id := 1;
    r23.created := sysdate;
    -- insert using record variable
    insert into t23
    values r23; 
end;
于 2010-12-07T18:17:44.563 回答