1 Reply Latest reply on Aug 17, 2005 3:25 PM by lafr

    CMP - default sysdate

    fss

      Hi,

      i have a cmp entity bean for one simple table tab_test (oracle9i).

      CREATE TABLE TAB_TEST(
       ID NUMBER NULL,
       INSERT_DATE DATE DEFAULT sysdate NOT NULL
      );
      
      ALTER TABLE TAB_TEST ADD (
       PRIMARY KEY (ID));
      


      The field insert_date has sysdate as default and could be autogenerated from the database. I tried to create a new entry, but I got the following error:


      13:19:22,698 INFO [STDOUT] javax.ejb.CreateException: Could not create entity:java.sql.SQLException: ORA-01400: cannot insert NULL into ("TEST"."TAB_TEST"."INSERT_DATE")


      I can only find articles about autogenerated primary keys! But the field Insert_date is not a primary key??

      Any suggestion?

      Thanx

        • 1. Re: CMP - default sysdate
          lafr

          The default value is used, if you don't give a value for the column in the insert statement.
          But NULL is take as a value for the column and the insert is rejected because null is not allowed.