oracle sql check constraint condition met -


beginner question: there way write check constraint restricts data condition met. instance, if want not allow appointment times between 1100 , 1300 on specific day.

alter table appointment_info  add constraint ap_time_ck check (ap_time not between 11 , 13); 

i tried

alter table appointment_info  add constraint ap_time_ck check (ap_time not between 11 , 13 , ap_date != '02-apr-2014'); 

but restrict appointment times between 1100 , 1300 , appointments on april 2nd.

that's possible solution:

alter table appointment_info add constraint ap_time_ck check (not (ap_time between 11 , 13 , ap_date = date '2014-04-02')); 

i against using this: '02-apr-2014' because can depend on nls settings.

or change and condition or in attempt. work.

alter table appointment_info add constraint ap_time_ck check (ap_time not between 11 , 13 or ap_date != '02-apr-2014'); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -