ORA-01400: cannot insert NULL

ORA-01400: cannot insert NULL

Postby ThomasMuellerUGIS » Thu 20 Jan 2011 13:24

Hi,

we now try using the DirectMode and get an exception during insert.
The error is ' ORA-01400: cannot insert NULL', but we did set a value.

Any Idea?

THX

Thomas



2011-01-20 14:18:41,538 ERROR [p526918=>CreateWorkflow(501209,System.Collections.Generic.List`1[System.Int32])] IssuanceEngine.Data.PumaDataContext Devart current DataContext queries log (exception):
2011-01-20 14:18:41,538 ERROR [p526918=>CreateWorkflow(501209,System.Collections.Generic.List`1[System.Int32])] IssuanceEngine.Data.PumaDataContext SELECT t1.ID, t1.WORKFLOW_INSTANCE_ID, t1.STATE_SEQUENCE, t1.TASK_SEQUENCE, t1.ACTION_SEQUENCE, t1.STATUS_ID, t1.FINISHED, t1.COMMENTS, t1.PROCESSING_SERVER, t1.MODIFICATION_DATE, t1.WORKFLOW_ID, t1.PRODUCT_ID, t1.STATEFUL_OBJECT_ID, t1.PREDECESSOR_ID, t1.PARENT_ID, t1.RETRY_COUNT, t1.SOPHIS_USER_ID, t1.CHILD_PRODUCT_ID
FROM PUMA_WORKFLOW_EXECUTION t1
WHERE t1.ID = :p0
-- p0: Input Number (Size = 0; DbType = Decimal) [0]
-- Context: Devart.Data.Oracle.Linq.Provider.OracleDataProvider Model: am Build: 1.0.43.0

SELECT SEQ_PUMA_WORKFLOW_EXECUTION.NEXTVAL FROM DUAL
-- Context: Devart.Data.Oracle.Linq.Provider.OracleDataProvider Model: am Build: 1.0.43.0

INSERT INTO PUMA_WORKFLOW_EXECUTION (ID, WORKFLOW_INSTANCE_ID, STATE_SEQUENCE, TASK_SEQUENCE, ACTION_SEQUENCE, STATUS_ID, FINISHED, COMMENTS, PROCESSING_SERVER, MODIFICATION_DATE, WORKFLOW_ID, PRODUCT_ID, STATEFUL_OBJECT_ID, PREDECESSOR_ID, PARENT_ID, RETRY_COUNT, SOPHIS_USER_ID, CHILD_PRODUCT_ID) VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18)
-- p1: Input Number (Size = 0; DbType = Decimal) [131925]
-- p2: Input Number (Size = 0; DbType = Decimal) [4443644]
-- p3: Input Number (Size = 0; DbType = Decimal) []
-- p4: Input Number (Size = 0; DbType = Decimal) []
-- p5: Input Number (Size = 0; DbType = Decimal) []
-- p6: Input Number (Size = 0; DbType = Decimal) [1]
-- p7: Input Number (Size = 0; DbType = Decimal) [False]
-- p8: Input NVarChar (Size = 0; DbType = String) []
-- p9: Input NVarChar (Size = 0; DbType = String) []
-- p10: Input TimeStamp (Size = 0; DbType = DateTime) [1/20/2011 1:18:37 PM]
-- p11: Input Number (Size = 0; DbType = Decimal) [0]
-- p12: Input Number (Size = 0; DbType = Decimal) []
-- p13: Input Number (Size = 0; DbType = Decimal) []
-- p14: Input Number (Size = 0; DbType = Decimal) []
-- p15: Input Number (Size = 0; DbType = Decimal) []
-- p16: Input Number (Size = 0; DbType = Decimal) [1]
-- p17: Input Number (Size = 0; DbType = Decimal) [8402]
-- p18: Input Number (Size = 0; DbType = Decimal) []
-- Context: Devart.Data.Oracle.Linq.Provider.OracleDataProvider Model: am Build: 1.0.43.0


2011-01-20 14:18:41,570 DEBUG [p526918=>CreateWorkflow(501209,System.Collections.Generic.List`1[System.Int32])] IssuanceEngine.Web.ServiceBase p526918=>CreateWorkflow(501209,System.Collections.Generic.List`1[System.Int32]): LinqCommandExecutionException: Devart.Data.Linq.LinqCommandExecutionException: Error on executing DbCommand. ---> Devart.Data.Oracle.OracleException: ORA-01400: cannot insert NULL into ("RISK_PUMA_DEV1"."PUMA_WORKFLOW_EXECUTION"."RETRY_COUNT")
at xc.t.d()
at Devart.Data.Oracle.bi.k()
at Devart.Data.Oracle.bi.c()
at Devart.Data.Oracle.p.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.System.Data.IDbCommand.ExecuteReader()
at Devart.Data.Linq.Provider.DataProvider.ExecuteQuery(String commandText, List`1 resultsetParameters, IList`1 parameters, Boolean isBatch, IDbCommand& dbCommand)
--- End of inner exception stack trace ---
at IssuanceEngine.Data.PumaDataContext.SubmitChanges(ConflictMode failureMode) in D:\projects\mainline\PumaEngine\IssuanceEngine.Data.Oracle\IssuanceEngineDbContext.cs:line 697
at Devart.Data.Linq.DataContext.SubmitChanges()
at ....
ThomasMuellerUGIS
 
Posts: 6
Joined: Wed 08 Dec 2010 18:57

Postby StanislavK » Mon 24 Jan 2011 13:07

Could you please specify the way you are creating and inserting the entity and, if possible, send us the exact model (or model with the related entity only) used for this? I've tried the following, and the insert was performed successfully:
Code: Select all
using (DataContext1 context = new DataContext1([connection string])) {

  context.PumaWorkflowExecutions.InsertOnSubmit(new PumaWorkflowExecution() {
    Id = 131928,
    WorkflowInstanceId = 4443644,
    StatusId = 1,
    Finished = 0,
    ModificationDate = DateTime.Now,
    WorkflowId = 0,
    RetryCount = 1,
    SophisUserId = 8402
  });

  context.SubmitChanges();
}

Also, did you try the latest 6.0.86 version of dotConnect for Oracle? Can the problem be reproduced with it?
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Postby bmarotta » Wed 02 Feb 2011 20:42

The problem is reproducible on 6.10

The entity is filled in more than one function, but basically we are doing something like this:

Code: Select all
entity = new PumaWorkflowExecution();
entity.Id = NextSequenceNumber();
context.PumaWorkflowExecutions.InsertOnSubmit(entity);
FillDataObject(entity);
context.SubmitChanges();


The correct implementation is done on the methods

Code: Select all
class BaseClass
{
...
        public virtual T Save(Data.PumaDataContext context)
        {
            bool found = true;
            T entity = GetDataObjectById(context);
            if (entity == null)
            {
                if (Id == 0)
                    Id = GetNextSequenceNumber();
                entity = new T();
                (entity as IUniqueIdentified).Id = Id; // Must add the Id here to avoid error on the InsertOnSubmit
                found = false;
            }

            if (!found)
                GetStorage(context).InsertOnSubmit(entity);

            FillDataObject(context, entity);

            return entity;
        }

        protected virtual void FillDataObject(Data.PumaDataContext context, T entity)
        {
            entity.Id = this.Id;
        }
}

class WorkflowExecution: BaseClass
{
...
        protected override void FillDataObject(Data.PumaDataContext context, Data.WorkflowExecution entity)
        {
            if (WorkflowInstanceId == null && WorkflowId == null)
                throw new Exception("Either the workflow instance id or the workflow identifier must be filled");
            base.FillDataObject(context, entity);
            entity.WorkflowInstanceId = WorkflowInstanceId;
            entity.StateSequence = StateSequence;
            entity.TaskSequence = TaskSequence;
            entity.ActionSequence = ActionSequence;
            entity.Finished = Finished;
            entity.StatusId = (int)Status;
            entity.ProcessingServer = ProcessingServer;
            entity.ModificationDate = ModificationDate;
            entity.Comments = Comments.Truncate(4000);
            entity.PredecessorId = PredecessorId;
            entity.ParentId = ParentId;
            if (WorkflowId.HasValue)
                entity.WorkflowId = WorkflowId.Value;
            entity.ProductId = ProductId;
            entity.StatefulObjectId = StatefulObjectId;
            entity.RetryCount = RetryCount;
            entity.SophisUserId = SophisUserId;
            entity.ChildProductId = ChildProductId;
        }
...
}
bmarotta
 
Posts: 34
Joined: Wed 29 Sep 2010 11:27

Postby StanislavK » Thu 03 Feb 2011 16:50

I will send you a test project in a letter, please specify what should be changed in it to reproduce the issue. The DDL script for the table used in the sample is specified in the comments of program.cs.

We could reproduce the issue only in case that the RetryCount property of the entity class is either version or an auto-generated field.
StanislavK
Devart Team
 
Posts: 1710
Joined: Thu 03 Dec 2009 10:48


Return to dotConnect for Oracle