Note that there are some explanatory texts on larger screens.

plurals
  1. POORA-01400 when trying to insert into schema.table.ID
    primarykey
    data
    text
    <p>I have a table that stores rejected contract proposals.</p> <pre><code>CREATE TABLE "STATUS_CONTRATO" ( "STC_ID" NUMBER NOT NULL, "CTB_CONTRATO" NUMBER NOT NULL, "STC_DATA" DATE NOT NULL, "STC_OBSERVACAO" VARCHAR2(200) NOT NULL, CONSTRAINT "STATUS_CONTRATO_PK" PRIMARY KEY ( "STC_ID") ENABLE VALIDATE, CONSTRAINT "FK_CONTRATO" FOREIGN KEY ( "CTB_CONTRATO") REFERENCES "CONTRATO" ( CTB_CONTRATO) ON DELETE SET NULL ENABLE VALIDATE) ; </code></pre> <p>(Script generated by Visual Studio 2010)</p> <p>This table has a simple Trigger, where the value of <code>STC_ID</code> is set:</p> <pre><code>TRIGGER "STATUS_CONTRATO_TRIGGER1" BEFORE INSERT ON "STATUS_CONTRATO" FOR EACH ROW when (new.STC_ID = 0) DECLARE BEGIN SELECT SEQ_STATUS_ID.NEXTVAL INTO :NEW.STC_ID FROM DUAL; END; </code></pre> <p><code>SEQ_STATUS_ID</code> is a simple sequence.</p> <p>Here's my problem:</p> <p>I can successfuly execute this insert in the VS2010 query window:</p> <pre><code>insert into myschema.STATUS_CONTRATO s( s.STC_ID, s.CTB_CONTRATO, s.STC_DATA, s.STC_OBSERVACAO )values( 0, 10, SYSDATE, 'Inserting by hand works' ); </code></pre> <p>But, when I try to insert using EF, I'm getting this exception:</p> <pre><code>System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---&gt; Oracle.DataAccess.Client.OracleException: ORA-01400: cannot insert NULL into ("MYSCHEMA"."STATUS_CONTRATO"."STC_ID") ORA-06512: at line 4 </code></pre> <p>I'm using this code to insert</p> <pre><code>STATUS_CONTRATO statusContrato = new STATUS_CONTRATO() { STC_ID = 0, CTB_CONTRATO = codContrato, STC_DATA = DateTime.Today, STC_OBSERVACAO = observacao }; ent.STATUS_CONTRATO.AddObject(statusContrato); ent.SaveChanges(); </code></pre> <p>I'm using VS2010, Oracle 11g (CentOS Server), ODP.NET client 11.2.0.3.0 Production, .NET Framework 4.0, EF 4.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload