I am getting an Oracle error ORA-01400 when attempting to insert a row into a table with a not-nullable column using Entity Framework, and not specifying a value for the column's scalar property on the entity. Is there any way to resolve this issue, aside from always assigning values for not-nullable columns? This poses potential problems if the default value of the column is changed, but the source code is not.
The column that I receive the error on is defined as follows:
Name = approval_required
Type = varchar2(1)
Nullable = False
Default = 'F'
I have included the error call stack and generated SQL below:
Devart.Data.Oracle.OracleException: ORA-01400: cannot insert NULL into ("LD5"."REVIEW_PATIENT_RESULT"."APPROVAL_REQUIRED")
ORA-06512: at line 4
at Devart.Data.Oracle.bp.b(Int32 A_0)
at Devart.Data.Oracle.ap.a(Int32 A_0, a4 A_1)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at Devart.Data.Oracle.Entity.k.a.a(CommandBehavior A_0)
at Devart.Data.Oracle.Entity.k.a.b(CommandBehavior A_0)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
declare
updatedRowid ROWID;
begin
insert into REVIEW_PATIENT_RESULT(DATAFACE_ID, REQ_SPECIMEN_ID, TEST_ID, RESULT, RESULT_GRAPHIC, RSLT_CODE, RSLT_CODE_TEXT, DELTA_NOTE, APPROVAL_REQUIRED, FLAG, ACTION)
values (:p0, :p1, :p2, :p3, null, :p4, :p5, :p6, null, :p7, :p8)
returning ROWID into updatedRowid;
open :outParameter for select REVIEW_PATIENT_RESULT_ID from REVIEW_PATIENT_RESULT where ROWID = updatedRowid;
end;
Regards,
Welton
ORA-01400 error...
In case you have default values for not null columns, the simplest solution is to set the StoreGeneratedPattern attribute to "Identity" for the Store properties corresponding to these not null columns.
In case you are using Devart Entity model then you can do this in design time, just go to the Model.Store node and set the appropriate properties.
In case you are using Microsoft ADO.NET Entity Data model, you will have to use XML Editor, go to the SSDL part of the model, and add to the proper property definitions.
In case you are using Devart Entity model then you can do this in design time, just go to the Model.Store node and set the appropriate properties.
In case you are using Microsoft ADO.NET Entity Data model, you will have to use XML Editor, go to the SSDL part of the model, and add
Code: Select all
StoreGeneratedPattern="Identity"