Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

max(id) of empty table evaluates to null

843317Feb 28 2011 — edited Feb 28 2011
Hello

I'm an absolute newbie to oracle and sql. My supervisor provided me this script

insert into country_property(id, country_id, name, value)
values ((select max(id) + 1 from country_property), (select country_code from country where name = 'TURKEY'), 'some_property', 't');

My problem is that the table is initially empty, such that max(id) evaluates to null which is forbidden by constraint. Can I fix that easily?

TIA, Bastl.

Edited by: 840314 on 28.02.2011 05:20 - NN constraint
This post has been answered by munky on Feb 28 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 28 2011
Added on Feb 28 2011
6 comments
2,878 views