Solved

ORA-01861 Error!!

Posted on 2006-07-20
5
569 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17152018
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
ID: 17152232
!!!!
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17152397
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

728 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