SQL Error Handling: Resolving ORA-01861 for Date Format Mismatch
When attempting to insert data into a table, you may encounter the error "ORA-01861: literal does not match format string." This error occurs when a date literal in the INSERT statement does not conform to the expected format.
In the specific case highlighted in the post, the error is likely caused by the date literal '1989-12-09' not matching the format expected by the column's data type. To resolve this, it is necessary to convert the string literal to a DATE value using the TO_DATE() function.
TO_DATE('1989-12-09','YYYY-MM-DD')
This function takes two arguments: the string literal representing the date and the format string specifying the format of the date. In this case, the format string 'YYYY-MM-DD' indicates that the date is in the format year-month-day.
By converting the string literal to a DATE value using TO_DATE(), you ensure that the date is inserted into the table in the correct format, thus resolving the ORA-01861 error.
The above is the detailed content of How to Resolve ORA-01861: Literal Does Not Match Format String in SQL?. For more information, please follow other related articles on the PHP Chinese website!