SQL 此处不允许使用虚拟列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16141786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:56:27  来源:igfitidea点击:

Virtual column not allowed here

sqloracle

提问by Ram Dutt Shukla

I am trying to insert a row in a table using VIEWas

我正在尝试使用VIEWas在表中插入一行

INSERT INTO FIELDI18N(LANGUAGE_ID) VALUES (1);

but it gives me following error:

但它给了我以下错误:

Error starting at line 5 in command:
INSERT INTO FIELDI18N(LANGUAGE_ID) VALUES (1)
Error at Command Line:5 Column:22
Error report:
SQL Error: ORA-01733: virtual column not allowed here
01733. 00000 -  "virtual column not allowed here"
*Cause:    
*Action:

Any Clue ?

任何线索?

Added the View Definition:

添加了视图定义:

CREATE OR REPLACE VIEW FIELDI18N("FIELDID", "NAME", "TYPE", "DESCRIPTION", "LANGUAGE_ID")
AS
  (SELECT field.fieldid,
    field.type,
    NVL(i18n.name, field.name) name,
    NVL(i18n.description, field.description) description,
    i18n.language_id
  FROM fields field
  JOIN i18n_fields i18n
  ON (field.fieldid    = i18n.fieldid)
  );

回答by David Aldridge

LANGUAGE_ID is probably a calculated field, or in any case the database cannot infer what change is to be made to the tables underlying the view based on the change you are requiring. Have to see the view definition code to know.

LANGUAGE_ID 可能是一个计算字段,或者在任何情况下,数据库都无法根据您需要的更改推断对视图下的表进行哪些更改。得看视图定义代码才知道。

回答by Hugh Seagraves

I believe that in order to do an insert or update using a view that all of the tables in the view must be joined via a primary key. This is to prevent duplicates caused by the view which cannot be updated.

我相信为了使用视图进行插入或更新,必须通过主键连接视图中的所有表。这是为了防止无法更新的视图导致重复。

回答by WW.

Is there a very good reason you are not just inserting into the underlying table? If you can, just insert into the table directly and avoid this complication.

是否有充分的理由不只是插入到基础表中?如果可以,只需直接插入表中即可避免这种复杂情况。

What are you expecting Oracle to do? Are you expecting it to insert a new record into i18n_fields?

您希望 Oracle 做什么?您是否希望它插入新记录i18n_fields

If you really want to do it like this you will need to create an INSTEAD OF trigger because Oracle can't figure out which of the underlying tables it should insert into when your run your insert statement.

如果您真的想这样做,您将需要创建一个 INSTEAD OF 触发器,因为 Oracle 在您运行插入语句时无法确定它应该插入哪个基础表。