Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
HI ALL

I HAD A SELECT QUERY WHILE EXECUTING I AM GETTING THE ERROR AS
ORA-01861: literal does not match format string
01861. 00000 -  "literal does not match format string"
*Cause:    Literals in the input must be the same length as literals in
           the format string (with the exception of leading whitespace).  If the
           "FX" modifier has been toggled on, the literal must match exactly,
           with no extra whitespace.

Here is my code kindly provide your suggestions.
SQL
select cust_folio_no,count(cust_folio_no),com_ref_no,customer_name,
 product_name from d_trxn_perm where
 LOAD_MMYY IN (to_char(add_months(SYSDATE,-1),'mmyyyy'),to_char(add_months(SYSDATE,-2),'mmyyyy'),
 to_char(add_months(SYSDATE,-3),'mmyyyy'))AND settlement_Date IN (to_char(add_months(SYSDATE,-1),'mmyyyy'),to_char(add_months(SYSDATE,-2),'mmyyyy'),
 to_char(add_months(SYSDATE,-3),'mmyyyy')) and rownum < 100000 and rbi_reject_code IN ('01','11','02','12','03','13','04','14','05','15') and
 client_recon_status_code in ('F','F1')
 group BY COM_REF_NO ,CUST_FOLIO_NO,CUSTOMER_NAME,product_name HAVING COUNT(cust_folio_no) = 3


Rgds
Jagadeshkumar
Posted
Updated 1-Jun-12 20:12pm
v2

1 solution

Without seeing your table definition, we can only guess...
SQL
settlement_Date IN 
(to_char(add_months(SYSDATE,-1),'mmyyyy'),to_char(add_months(SYSDATE,-2),'mmyyyy'), to_char(add_months(SYSDATE,-3),'mmyyyy'))

My guess is: settlement_Date is a date, which cannot be compared to a string of length six.

Try this:

SQL
to_char(settlement_Date,'mmyyyy')
-------
IN (to_char(add_months(SYSDATE,-1),'mmyyyy'),
    to_char(add_months(SYSDATE,-2),'mmyyyy'), 
    to_char(add_months(SYSDATE,-3),'mmyyyy'))


Hope this helps,
Pablo.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900