I was given the following code to create some tables in MySQL:
create table vt_staff (
stf_id decimal(6,0) primary key
, stf_name_last varchar(25) not null
, stf_name_first varchar(25) not null
, stf_job_title varchar(25) not null
, constraint stf_id_range check (stf_id > 0)
, constraint job_title_values
check ( stf_job_title in ('vet', 'vet assnt', 'clerical', 'kennel'))
);
create table vt_animals(
an_id decimal(6,0) primary key
, an_type varchar(25) not null
, an_name varchar(25) null
, an_dob date not null
, cl_id decimal(6,0) not null
, constraint an_id_range check (an_id > 0)
, constraint an_dob_ck check (trunc(an_dob) = an_dob)
);
create table vt_exam_headers(
ex_id decimal(6,0) primary key
, an_id decimal(6,0) not null
, stf_id decimal(6,0) not null
, ex_date date not null
, constraint vt_exam_headers_animal_fk foreign key(an_id) references vt_animals
, constraint vt_exam_headers_staff_fk foreign key(stf_id) references vt_staff
, constraint ex_id_range check (ex_id > 0)
, constraint exam_date_range check (ex_date >= date '2010-01-01')
);
All the code executed fine. However when I tried running the following insert statements for the vt_exam_headers table, I keep obtaining an error, e.g..,
insert into vt_exam_headers(ex_id, an_id, stf_id, ex_date)
values (2289, 21320, 38, TO_DATE('2015-04-11 13:00', 'YYYY-MM-DD HH24:MI') );
insert into vt_exam_headers(ex_id, an_id, stf_id, ex_date)
values (2290, 21320, 38, TO_DATE('2015-04-11 17:00', 'YYYY-MM-DD HH24:MI') );
I believe the problem is related to the TO_DATE function, but am not sure of the correct syntax.
Would appreciate any help.