Home > Database > Mysql Tutorial > How to Resolve the ORA-01861: Literal does not match format string Error in Oracle?

How to Resolve the ORA-01861: Literal does not match format string Error in Oracle?

Patricia Arquette
Release: 2024-12-30 10:58:09
Original
515 people have browsed it

How to Resolve the ORA-01861: Literal does not match format string Error in Oracle?

Error ORA-01861: Resolving DateTime Format Mismatch

Encountering error ORA-01861 when inserting data into a table is indicative of a mismatch between the format of the input literal and the expected format specified in the SQL statement. To resolve this error, it's crucial to ensure that both formats align.

Specifically, in the given example, the issue lies with the DOB (date of birth) field in the INSERT statement:

DOB,
'1989-12-09',
Copy after login

The literal string '1989-12-09' does not match the implicit format expected by the Oracle database for date values. To rectify this, you can use the TO_DATE() function to explicitly convert the string into a date value with the correct format:

DOB,
TO_DATE('1989-12-09', 'YYYY-MM-DD')
Copy after login

In this case, the TO_DATE function takes the first argument as the string representation of the date, and the second argument specifies the format of that string. The 'YYYY-MM-DD' format ensures that the date is interpreted as a year-month-day value.

Oracle requires that the literal data provided for insertion matches the format expected by the target column. By converting the DOB string literal to the correct format using TO_DATE(), you can eliminate the ORA-01861 error and successfully insert the data into the table.

The above is the detailed content of How to Resolve the ORA-01861: Literal does not match format string Error in Oracle?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template