SQL Error: ORA-01861: literal does not match format string 01861

后端 未结 7 927
长情又很酷
长情又很酷 2020-11-29 04:33

I am trying to insert data into an existing table and keep receiving an error.

INSERT INTO Patient  
(
  PatientNo,
  PatientFirstName,
  PatientLastName,
           


        
相关标签:
7条回答
  • 2020-11-29 04:45

    You can also change the date format for the session. This is useful, for example, in Perl DBI, where the to_date() function is not available:

    ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'
    

    You can permanently set the default nls_date_format as well:

    ALTER SYSTEM SET NLS_DATE_FORMAT='YYYY-MM-DD'
    

    In Perl DBI you can run these commands with the do() method:

    $db->do("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD');
    

    http://www.dba-oracle.com/t_dbi_interface1.htm https://community.oracle.com/thread/682596?start=15&tstart=0

    0 讨论(0)
  • 2020-11-29 04:50

    try to save date like this yyyy-mm-dd hh:mm:ss.ms for example: 1992-07-01 00:00:00.0 that worked for me

    0 讨论(0)
  • 2020-11-29 05:00

    The format you use for the date doesn't match to Oracle's default date format.

    A default installation of Oracle Database sets the DEFAULT DATE FORMAT to dd-MMM-yyyy.

    Either use the function TO_DATE(dateStr, formatStr) or simply use dd-MMM-yyyy date format model.

    0 讨论(0)
  • 2020-11-29 05:05

    If you provide proper date format it should work please recheck once if you have given correct date format in insert values

    0 讨论(0)
  • 2020-11-29 05:08

    Try the format as dd-mon-yyyy, For example 02-08-2016 should be in the format '08-feb-2016'.

    0 讨论(0)
  • 2020-11-29 05:09

    Try replacing the string literal for date '1989-12-09' with TO_DATE('1989-12-09','YYYY-MM-DD')

    0 讨论(0)
提交回复
热议问题