Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lookup Error ORA-00932: inconsistent datatypes: expected DATE got NUMBER

Tags:

sql

oracle

When I try to run this query I get the above error. Could some one help me on this

UPDATE CCO.ORDER_CREATION 
   SET "Doc_Date" = 8/9/2013 
 WHERE "Document_Number" IN (3032310739,3032310740,3032310738)
like image 762
santhosha Avatar asked Aug 20 '13 08:08

santhosha


People also ask

How do I fix not valid Month error in Oracle?

To fix the error, specify a month value that is valid such as “January”. Some conversion is built-in, and a value of “Jan” is also valid for the Month format code.

What is the date format in Oracle?

Oracle stores dates in an internal numeric format representing the century, year, month, day, hours, minutes, seconds. The default date format is DD-MON-YY.

Is not a group by expression?

ORA-00979 “ Not a GROUP BY expression ” is an error issued by the Oracle database when the SELECT statement contains a column that is neither listed in GROUP BY nor aggregated. This error message can be confusing to beginners.


2 Answers

8/9/2013 is a numeric value: 8 divided by 9 divided by 2013.

You should use the to_date() function in order to convert a string to a date:

UPDATE CCO.ORDER_CREATION 
   SET "Doc_Date" = to_date('08/09/2013', 'dd/mm/yyyy')
 WHERE "Document_Number" IN (3032310739,3032310740,3032310738);

You might need to adjust the format mask, as it's unclear whether you mean August, 9th or September 8th

Alternatively you can use the an ANSI date literal (the format is always yyyy-mm-dd for an ANSI SQL date literal):

UPDATE CCO.ORDER_CREATION 
   SET "Doc_Date" = DATE '2013-09-08'
 WHERE "Document_Number" IN (3032310739,3032310740,3032310738);
like image 65
a_horse_with_no_name Avatar answered Oct 20 '22 22:10

a_horse_with_no_name


Try this

UPDATE CCO.ORDER_CREATION 
   SET "Doc_Date" =   TO_DATE('8/9/2013', 'MM/DD/YYYY')
 WHERE "Document_Number" IN (3032310739,3032310740,3032310738)
like image 45
Rahul Tripathi Avatar answered Oct 20 '22 22:10

Rahul Tripathi