**已关闭。**此问题需要debugging details。它目前不接受回答。
编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答这个问题。
24天前关闭
Improve this question的
我有Oracle数据库,它有多个表(其中三个表的ID列总是生成标识),需要连接到Windows窗体。
分解表
CREATE TABLE "BREAKDOWN"
("EQUIPMENTID" NCHAR(8) NOT NULL ENABLE,
"FROMTIME" TIMESTAMP (4),
"TOTIME" TIMESTAMP (4),
"WORKORDER" NUMBER(10,0) NOT NULL ENABLE,
"BDNREASON" NCHAR(10),
"BDNTIME" INTERVAL DAY (2) TO SECOND (6) GENERATED ALWAYS AS (("TOTIME"-"FROMTIME")DAY(9) TO SECOND(4)) VIRTUAL ,
"BREAKDOWNID" NUMBER(10,0) GENERATED ALWAYS AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOT NULL ENABLE,
CONSTRAINT "BREAKDOWN_PK" PRIMARY KEY ("BREAKDOWNID") )
字符串
BREAKDOWN生成的类
public partial class BREAKDOWN
{
public string EQUIPMENTID { get; set; }
public Nullable<System.DateTime> FROMTIME { get; set; }
public Nullable<System.DateTime> TOTIME { get; set; }
public int WORKORDER { get; set; }
public string BDNREASON { get; set; }
public int BREAKDOWNID { get; set; }
public Nullable<decimal> BDNTIME { get; set; }
public virtual EQUIPMENT EQUIPMENT { get; set; }
public virtual WORKORDER WORKORDER1 { get; set; }
}
型
WORKORDER表
CREATE TABLE "WORKORDER"
(
"WORKORDERTYPEID" NCHAR(3) NOT NULL ENABLE,
"WORKORDEREQUIPMENTID" NCHAR(8) NOT NULL ENABLE,
"WORKORDERREGISTERATIONDATE" TIMESTAMP (3) NOT NULL ENABLE,
"WORKORDERID" NUMBER(10,0) GENERATED ALWAYS AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE NOT NULL ENABLE,
CONSTRAINT "WORKORDER_PK" PRIMARY KEY ("WORKORDERID")
)
型
WORKORDER生成的类
public partial class WORKORDER
{
public WORKORDER()
{
this.BREAKDOWNs = new HashSet<BREAKDOWN>();
}
public string WORKORDERTYPEID { get; set; }
public string WORKORDEREQUIPMENTID { get; set; }
public System.DateTime WORKORDERREGISTERATIONDATE { get; set; }
public int WORKORDERID { get; set; }
}
型
如果我尝试使用ORACLE SQL Developer进行INSERT,则IDENTITY对这三个表可以正常工作
whileas如果我尝试使用Windows窗体视图使用(Add()Function)插入,则会引发上述错误:
System.Data.Entity.Infrastructure.DbUpdateException:'更新条目时出错。有关详细信息,请参见内部异常。更新条目时出错。有关详细信息,请参见内部异常。OracleException:ORA-54013:不允许对虚拟列执行INSERT操作ORA-06512:在4号线
仅在BREAKDOWN时出现此情况
BREAKDOWN newBDN = new BREAKDOWN();
newBDN.WORKORDER = workOrder.WORKORDERID;
newBDN.EQUIPMENTID = workOrder.WORKORDEREQUIPMENTID;
newBDN.FROMTIME = bdnFromDateTimePicker.Value;
home.dbContext.BREAKDOWNs.Add(newBDN);
home.dbContext.SaveChanges();
型
而WORKORDER表运行正常!!
WORKORDER newWorkOrder= new WORKORDER ();
newWorkOrder.EQUIPMENT = (EQUIPMENT) equipmentBindingSource.DataSource;
newWorkOrder.WORKORDERREGISTERATIONDATE = regsiterationDatePicker.Value;
newWorkOrder.WORKORDERTYPE = (WORKORDERTYPE)workTypeTextBox.SelectedItem;
home.dbContext.WORKORDERs.Add(newWorkOrder);
home.dbContext.SaveChanges();
型
我已保证:
- 列均为具有所需ISEQ的IDENTITY。
- 所有列的数据类型在DBTables和Entity中是相同的。
- ORACLE正在正确计算IDENTITY属性(使用ORACLE SQL Developer手动插入)
1条答案
按热度按时间bttbmeg01#
我认为这不是 identity 列,而是另一个- virtual列。例如,类似这样的东西:见第7行,哪一行是虚拟列?
字符串
如果我尝试在其中插入值,Oracle会引发错误(与您得到的相同):
型
如果省略
total
:型
因此,检查这些表中是否有任何虚列。怎么做?像这样:
型