3

I'm creating a table on our database with version Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64b

create table tahakkuk_kalem(
                           id       int generated always as identity primary key,       
                           aciklama varchar2(250),
                           tur      int default 0 not null 
                          );

and then applying some insert statements :

SQL> insert into tahakkuk_kalem(aciklama) select 'Atıksu' from dual;

SQL> select * from tahakkuk_kalem;

ID  ACIKLAMA  TUR
--  --------  --- 
1   Atıksu     0

SQL> rollback;

SQL> insert into tahakkuk_kalem(aciklama,tur) select 'Atıksu',0 from dual;

ID  ACIKLAMA  TUR
--  --------  --- 
2   Atıksu     0

SQL> rollback;

So far so good, but if I issue the statement below ;

SQL> insert into tahakkuk_kalem(aciklama,tur) 
     select 'Atıksu',0 from dual union all select 'Ceza',0 from dual;

met an incomprehensible error statement :

ORA-01400: cannot insert NULL into ("MY_SCHEMA"."TAHAKKUK_KALEM"."ID")

Do you have any opinion what could be the reason ?

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
  • 1
    I replicated this in a Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 environment and in a Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 environment. 12.2 works just fine, while 12.1 threw the error mentioned from you. Maybe there is a problem with 12.1 version. – Ergi Nushi Dec 19 '19 at 19:50
  • 1
    Does this answer your question? [Oracle identity column and insert into select](https://stackoverflow.com/questions/21355770/oracle-identity-column-and-insert-into-select) – Alessandro Melo Dec 19 '19 at 19:53
  • thank you very much @AlessandroMelo that answers. Very interesting. – Barbaros Özhan Dec 19 '19 at 20:10
  • yes, that should be a bug, thanks @ErgiNushi . – Barbaros Özhan Dec 19 '19 at 20:11

0 Answers0