A non numeric character was found where a numeric was expected ошибка

The error you are getting is either because you are doing TO_DATE on a column that’s already a date, and you’re using a format mask that is different to your nls_date_format parameter[1] or because the event_occurrence column contains data that isn’t a number.

You need to a) correct your query so that it’s not using TO_DATE on the date column, and b) correct your data, if event_occurrence is supposed to be just numbers.

And fix the datatype of that column to make sure you can only store numbers.

[1] What Oracle does when you do: TO_DATE(date_column, non_default_format_mask) is:
TO_DATE(TO_CHAR(date_column, nls_date_format), non_default_format_mask)

Generally, the default nls_date_format parameter is set to dd-MON-yy, so in your query, what is likely to be happening is your date column is converted to a string in the format dd-MON-yy, and you’re then turning it back to a date using the format MMDD. The string is not in this format, so you get an error.

May 2, 2021

I got ” ORA-01858: a non-numeric character was found where a numeric was expected ” error in Oracle database.

ORA-01858: a non-numeric character was found where a numeric was expected

Details of error are as follows.

ORA-01858: a non-numeric character was found where a numeric was expected

Cause: The input data to be converted using a date format model was incorrect. 
The input data did not contain a number where a number was required by the format model.

Action: Fix the input data or the date format model to make sure the elements match in 
number and type. Then retry the operation.



a non-numeric character was found where a numeric was expected

This ORA-01858 errors are related with the The input data to be converted using a date format model was incorrect.
The input data did not contain a number where a number was required by the format model.

To solve this error, you need to Fix the input data or the date format model to make sure the elements match in
number and type. Then retry the operation.

An example of the this error as follows:

The DATA in SCOTT.EMP is as follows:

EMPNO   ENAME       JOB       MGR        HIREDATE   SAL   COMM    DEPTNO
------- ----------  --------- ---------- ---------  ----- ------- ----------
7900    JAMES       CLERK     7698       03-DEC-81  950           30
7902    FORD        ANALYST   7566       03-DEC-81  3000          20
7934    MILLER      CLERK     7782       23-JAN-82  1300          10
8000    HAMBURGLAR  THIEF     7698       03-MAR-09  100           30
SQL> alter session set NLS_DATE_FORMAT='MM/DD/YYYY';

Session altered.

SQL> alter session set NLS_TIMESTAMP_FORMAT='YYYY-MM-DD-hh24.mi.ss.ff';

Session altered.


SQL> select *
       from scott.emp
      where job='THIEF'
        and TO_DATE(TO_CHAR(HIREDATE, 'DD-MON-YY')) = TO_DATE(TO_CHAR(sysdate-1, 'DD-MON-YY'));

select * from scott.emp where job='THIEF' and TO_DATE(TO_CHAR(HIREDATE, 'DD-MON-YY')) = TO_DATE(TO_CHAR(sysdate-1, 'DD-MON-YY'))
*
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected


SQL> select /*+ rule*/*
       from scott.emp
      where job='THIEF'
        and TO_DATE(TO_CHAR(HIREDATE, 'DD-MON-YY')) = TO_DATE(TO_CHAR(sysdate-1, 'DD-MON-YY'));

select /*+ rule*/* from scott.emp where job='THIEF' and TO_DATE(TO_CHAR(HIREDATE, 'DD-MON-YY')) = TO_DATE(TO_CHAR(sysdate-1, 'DD-MON-YY'))
*
ERROR at line 1:
ORA-01843: not a valid month

Once the NLS Formats are changed back the query now executes without error:

SQL> alter session set NLS_DATE_FORMAT='DD-MON-RR';

Session altered.

SQL> alter session set NLS_TIMESTAMP_FORMAT='DD-MON-RR HH.MI.SSXFF AM';

Session altered.


SQL> select *
       from scott.emp
      where job='THIEF'
        and TO_DATE(TO_CHAR(HIREDATE, 'DD-MON-YY')) = TO_DATE(TO_CHAR(sysdate-1, 'DD-MON-YY'));

no rows selected

SQL> select /*+ rule*/*
       from scott.emp
      where job='THIEF'
        and TO_DATE(TO_CHAR(HIREDATE, 'DD-MON-YY')) = TO_DATE(TO_CHAR(sysdate-1, 'DD-MON-YY'));

no rows selected

You need to read the following post to learn more details about TO_DATE function.

PL/SQL Datetime Functions

Do you want to learn Oracle Database for Beginners, then read the following articles.

Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

 2,385 views last month,  1 views today

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

ORA-01858

ORA-01858: в дате была обнаружена буква в том месте где должно стоять число

Причина:

Входные данные были преобразованы с использованием картинки формата даты, который был неверен; в картинке формата ожидалось число, но на его месте была обнаружена буква.

Действие:

Проверьте входные данные и картинку формата даты, для того чтобы убедиться, что ее элементы отождествляются в числах, затем повторите операцию.

oracle tutorial webinars

ORA-01858

Sometimes in working with database software, matters of syntax and formatting can overlap to create a plethora of problems for users. Some platforms may require only numerical digits in certain sections. Others may need the month in a date written out in full and phonetic form.

Despite the needs of the program, it would be impossible for any one individual to strictly adhere to the parameters of Oracle on every occasion. The ORA-01858 can be considered as a warning to users are jumping between various tables and data sets at a quick pace and are letting the formatting concerns slip through the cracks.

The Problem

The ORA-01858 error is an issue of syntax and formatting. When prompted with the error, the user will receive an accompanying message that will state that “a non-numeric character was located where a digit was expected”. Oracle docs list the cause of this error as “the input data to be converted using a date format model being incorrect. The input data did not contain a number where a number was required by the format model.”

What does this mean in simple terms? This error essentially occurs when a user attempts to convert a string of data into a date, and in doing so specified a date being passed in a particular format. This will most commonly be something along the lines of DD-MM-YYYY. The error pops up when the user then tries to pass the date in the DD-MON-YYYY format. In such a case, a character-stated month such as “JAN” for January or “JUL” for July, will cause the error by inserting an alphabetical name in a place that Oracle expects to read a numerical name (such as “01” for January or “07” for July). Because this error is prompted by a character presence in a numerically-determined field, the most likely culprit will be a date entered in a format that writes the month specifically out in some form.

The Solution

In order to solve this formatting issue, there are basically two options to take. The user can either fix the input data to conform to the format in question, or the user can switch the date format model to ensure that the elements match in number and type and then retry the operation. In most cases, the former will be the simpler strategy.

Before we continue, it would be important to note that if a user is attempting to fetch strings from a table and subsequently convert them into dates, the data in the table should be checked prior to using the date format string. If the table contained strings that are note actually date values and the user attempts to convert them, then this error could be raised (although this is less common).

Since there is no predefined exception for handling this specific error, let us look at an example of a user-defined way of addressing it. In this scenario, the default date format is set to DD-MON-YY and the following statement was executed:

SQL> select to_date(’10-JUN-2014’, ‘DD-MM-YYYY’) from dual;
ERROR:

ORA-01858: a non-numeric character was found where a numeric was expected
no rows selected

At this juncture, after assessing the data and determining that the date information needs to be adjusted, the following can be run:

SQL> select to_date(’10-JUN-2014’, ‘DD-MON-YYYY’) from dual
2 /
TO_DATE( ‘ 10
10-JUN-2014

This should clear up the hypothetical date in question and allow the statement to run smoothly.

Looking forward

Formatting issues can be mentally taxing simply because they can allow a user to second-guess themselves on what information is where. It would be recommended that if you are finding yourself getting frustrated and having to look back to the same information repeatedly, write down the bits that are concrete and a part of your system for reference points. If you are having further concerns over formatting or this error specifically, contacting a licensed Oracle consulting representative can clear up any other database questions.

totn Oracle Error Messages


Learn the cause and how to resolve the ORA-01858 error message in Oracle.

Description

When you encounter an ORA-01858 error, the following error message will appear:

  • ORA-01858: a non-numeric character found where a digit was expected

Cause

You tried to enter a date value using a specified date format, but you entered a non-numeric character where a numeric character was expected.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Check the date formats recognized by the TO_DATE function. Correct the date value and retry.

Возможно, вам также будет интересно:

  • A14net не заводится ошибок нет
  • A13 danfoss vlt ошибка
  • A12 815 buderus ошибка
  • A0c1 ошибка bmw e90
  • A0c1 ошибка bmw e71

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии