需要有关 Oracle 10g Express 版本的帮助

发布于 2024-10-06 04:22:35 字数 522 浏览 1 评论 0原文

当我尝试在下表中插入记录时,出现错误“ora-03001:未实现的功能”。我找了一整夜,还是没有成功。我使用的是 Oracle10g Express 版本。

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'));

I got error "ora-03001: unimplemented feature" when I try to insert a record on table below. I've searched all night, still no luck. I'm using Oracle10g express edition.

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'));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2024-10-13 04:22:35

这是一个简单的语法错误: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;

It's a simple syntax error: the VALUES clause requires everything to be wrapped in parentheses:

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

1 row created.

SQL>

This applies whether we're passing in several scalar values or a single type.


The one case when it doesn't apply is an insert in PL/SQL using a RECORD type. Which is not relevant to your situation, but I'm mentioning it for completeness.

Inserting a RECORD variable would look something like this

declare
    r23 t23%rowtype;  -- record declaration
begin
    r23.id := 1;
    r23.created := sysdate;
    -- insert using record variable
    insert into t23
    values r23; 
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文