插入视图时,“ORA-01733:此处不允许使用虚拟列”

问题描述 投票:1回答:1

我创建了一个名为“view_employee”的视图,如下所示:

CREATE VIEW view_employee AS
SELECT employee.surname || ', ' || employee.name AS comp_name, employee.sex, sections.name AS section_name, employee_age
FROM sections, employee WHERE employee.section = sections.sect_code;

我想使用视图将数据插入表中,如下所示:

INSERT INTO view_employee VALUES ('Doe, John', 'm', 'Marketing', 34);

以下是表的列和约束:

create table sections(
  sect_code number(2),
  name varchar2(20),
  income number(5,2)
   constraint CK_sections_income check (income>=0),
  constraint PK_sections primary key (sect_code)
 );

 create table staff(
  ident number(5),
  document char(8),
  sex char(1)
   constraint CK_staff_sex check (sex in ('f','m')),
  surname varchar2(20),
  name varchar2(20),
  address varchar2(30),
  section number(2) not null,
  age number(2)
   constraint CK_staff_age check (age>=0),
  marital_status char(10)
   constraint CK_employee_marital_status check (marital_status in 
('married','divorced','single','widower')),
  joindate date,
   constraint PK_employee primary key (ident),
  constraint FK_employee_section
   foreign key (section)
   references sections(sect_code),
  constraint UQ_staff_document
   unique(document)
);

我尝试插入时得到的错误消息如下:

Error starting at Command Line: 1 Column : 1
Error report -
SQL Error: ORA-01733: virtual column not allowed here
01733. 00000 -  "virtual column not allowed here"
*Cause:    
*Action:

如何使用视图将这些值插入表中?提前致谢。

sql oracle10g sql-insert sql-view
1个回答
0
投票

视图不得包含以下任何构造。所以,它可以更新。

  • 一组运算符
  • DISTINCT运算符
  • 聚合或分析函数
  • GROUP BY,ORDER BY,MODEL,CONNECT BY或START WITH子句
  • SELECT列表中的集合表达式
  • SELECT列表中的子查询
  • 指定WITH READ ONLY的子查询
  • 如Oracle数据库管理员指南中所述,加入了一些例外情况。
© www.soinside.com 2019 - 2024. All rights reserved.