Location>code7788 >text

[YashanDB Knowledge Base] Error when importing data: YAS-00008 type convert error: literal does not match format string

Popularity:767 ℃/2025-01-16 10:16:07

The content of this article comes from the YashanDB official website. Please see the original content./newsinfo/?templateId=1718516

Phenomenon

When importing data into Yashan through SQL language, an error occurs: YAS-00008 type convert error: literal does not match format string

reason

Insert a date type string, which is not the configuration parameter specified by the configuration parameter DATE_FORMAT. The database's default DATE_FORMAT='yyy-mm-dd', if the inserted period type string is '2024-12-16 11:27:03', this error will be reported. For example:

CREATE TABLE test(f date); -- There is a date field in the imported table

insert into test(f) values('2024-12-16 11:27:03'); -- Date type string of imported data

The error "literal does not match format string" will be reported. It can be considered that when inserting, the database DATE_FORMAT format is converted to to_date and an error is reported in the form: SELECT to_date('2024-12-16 11:27:03', 'yyyy-mm- dd') FROM dual;

The same error will be reported.

Solution

1. Modify the configuration parameter DATE_FORMAT to the imported time format, use 'yyyy-mm-dd hh24:mi:ss' for '2024-12-16 11:27:03'

alter system set DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' scope=spfile; --After modification, the database parameters need to be restarted to take effect

2. Do not modify the configuration parameter DATE_FORMAT. Specific statements specify the conversion format, such as:

insert into test values(to_date('2024-12-16 11:27:03', 'yyyy-mm-dd hh24:mi:ss'));