Solved

ORA-01861 Error!!

Posted on 2006-07-20
5
559 Views
Last Modified: 2008-01-09
Hi,


The following exception is caught while running my aplication.

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

The exception is caught while trying to insert data into a temporary table

The temporary table is created using the following query.
-------------------------------------------------------------------
CREATE GLOBAL TEMPORARY TABLE TempAvgDistRecords  
(
PROJEKTID NUMBER,
FIRMAID VARCHAR(20),
GEBIETID VARCHAR(20),
DATUM DATE,
DATUMVON DATE,
DATUMBIS DATE
)
-------------------------------------------------------------------



Query which fetches data is as follows
------------------------------------------------------------------------------------------------------------------
SELECT DISTINCT PJDT.PROJEKTID, PJDT.FIRMAID, PJDT.DATUM, PJVS.GEBIETID, PJVS.DATUMVON,
PJVS.DATUMBIS FROM PJDT, PJVS,GB, GBSU WHERE PJDT.PROJEKTID = PJVS.PROJEKTID
AND PJDT.FIRMAID = PJVS.FIRMAID  AND GB.GEBIETID = PJVS.GEBIETID AND
GB.GEBIETID = GBSU.GEBIETID AND (GBSU.SUBJEKTIDPE = 'pe01293')
AND (PJDT.DATUM BETWEEN '01-Jul-2006' and '19-Jul-2006')}
-------------------------------------------------------------------------------------------------------------------










The output of the above query is as follows:

------------------------------------------------------------------------------------------------
PROJEKTID FIRMAID              DATUM     GEBIETID             DATUMVON
---------- -------------------- --------- -------------------- ---------
DATUMBIS
---------
      7714 4                    01-JUL-06 011-000-000-201-0009 01-JAN-00
31-DEC-99

      7714 4                    08-JUL-06 011-000-000-201-0009 01-JAN-00
31-DEC-99

      7714 4                    15-JUL-06 011-000-000-201-0009 01-JAN-00
31-DEC-99


 PROJEKTID FIRMAID              DATUM     GEBIETID             DATUMVON
---------- -------------------- --------- -------------------- ---------
DATUMBIS
---------
      7742 4                    11-JUL-06 011-000-000-201-0009 01-JAN-00
31-DEC-99
---------------------------------------------------------------------------------

The “ORA-01861: literal does not match format string”  exception  is caught while trying to insert the above output data into the Temporary Table which have been created in the beginning.

Can anyone resolve this issue???


0
Comment
Question by:akshay_sumeru
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
AND (PJDT.DATUM BETWEEN TO_DATE('01-Jul-2006' , 'DD-MON-YYYY') and to_date('19-Jul-2006', 'DD-MON-YYYY') )
0
 

Author Comment

by:akshay_sumeru
Comment Utility
!!!!
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
I see what is probably wrong.

you created the table with these fields:

CREATE GLOBAL TEMPORARY TABLE TempAvgDistRecords  
(
PROJEKTID NUMBER,
FIRMAID VARCHAR(20),
GEBIETID VARCHAR(20),
DATUM DATE,
DATUMVON DATE,
DATUMBIS DATE
)

but your query takes them in another order, ie DATUM before GEBIETID

SELECT DISTINCT PJDT.PROJEKTID, PJDT.FIRMAID, PJDT.DATUM, PJVS.GEBIETID, PJVS.DATUMVON,
PJVS.DATUMBIS FROM PJDT, PJVS,GB, GBSU WHERE PJDT.PROJEKTID = PJVS.PROJEKTID
AND PJDT.FIRMAID = PJVS.FIRMAID  AND GB.GEBIETID = PJVS.GEBIETID AND
GB.GEBIETID = GBSU.GEBIETID AND (GBSU.SUBJEKTIDPE = 'pe01293')
AND (PJDT.DATUM BETWEEN '01-Jul-2006' and '19-Jul-2006')}

so, change the SELECT field order for your insert:

SELECT DISTINCT PJDT.PROJEKTID, PJDT.FIRMAID, PJVS.GEBIETID, PJDT.DATUM, PJVS.DATUMVON,
PJVS.DATUMBIS FROM PJDT, PJVS,GB, GBSU WHERE PJDT.PROJEKTID = PJVS.PROJEKTID
AND PJDT.FIRMAID = PJVS.FIRMAID  AND GB.GEBIETID = PJVS.GEBIETID AND
GB.GEBIETID = GBSU.GEBIETID AND (GBSU.SUBJEKTIDPE = 'pe01293')
AND (PJDT.DATUM BETWEEN '01-Jul-2006' and '19-Jul-2006')}


0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now