0

I dont know why its going wrong. i tried several alternatives and coming up with this error. can someone help please?

INSERT INTO ClientAppointment (Appointment_ID, Customer_ID, AppointmentDateTime, EmployeeID)
VALUES ('4472', '7753', '2017-08-01', '788678');
GMB
  • 216,147
  • 25
  • 84
  • 135
NAJ22
  • 3
  • 4

1 Answers1

2

You should explicitly cast the string to a date. Else, you rely on Oracle's ability to do that for you under the hood, which itself depends on whether the string matches the NLS_DATE_FORMAT of your database or session.

For this, you can do:

INSERT INTO ClientAppointment (Appointment_ID, Customer_ID, AppointmentDateTime, EmployeeID) 
VALUES (4472, 7753, date '2017-08-01', 788678);

This works because the format of your string corresponds to the ISO format for a date. In other situations, you would use to_date():

INSERT INTO ClientAppointment (Appointment_ID, Customer_ID, AppointmentDateTime, EmployeeID) 
VALUES (4472, 7753, to_date('2017-08-01', 'yyyy-mm-dd'), 788678);

Note: other values look like numbers, so I suspect they are. If so, you should treat them as such (ie not surround them with quotes).

GMB
  • 216,147
  • 25
  • 84
  • 135