John the Ripper
John the Ripper

Reputation: 2439

LOCATE function produces error "OAR-01861: literal does not match format string"

Very new to Oracle.

I'm using some code from a friend but it's producing the above mentioned error.

select count(REFERENCE_#)
from ARADMIN.ALL_REQUESTS
where (DATE_OCCURRED >= add_months(sysdate, -12) )
and ({FN LOCATE('INFO-MGMT-SRVCS.R3', "ALL_REQUESTS"."TRACE_LOG")} > 0)

I google around and most of the hits were related to dates, so my newbie assumption is that Oracle is trying to convert the string literal 'INFO-MGMT-SRVCS.R3' to a date.

Is this correct?

If so how do I tell it that this is in fact a string and should remain as is?

If I'm incorrect why am I getting this error?

Thanks

Edit:

I just tried

select count(REFERENCE_#)
from ARADMIN.ALL_REQUESTS
where (DATE_OCCURRED >= add_months(sysdate, -12) )
and ({FN LOCATE('foo', "ALL_REQUESTS"."TRACE_LOG")} > 0)

and it gave me the same error so my assumption was wrong.

Edit 2: This appears to be related to my first where clause (DATE_OCCURRED >= add_months(sysdate, -12) ). I thought it had to do with my second one because of the line number the error message was reporting.

Final Edit:

Working code:

select count(REFERENCE_#)
from ARADMIN.ALL_REQUESTS
where (to_date(DATE_OCCURRED, 'YYYY-MM-DD HH24:MI:SS') >= add_months(sysdate, -12) )
and ({FN LOCATE('INFO-MGMT-SRVCS.R3', "ALL_REQUESTS"."TRACE_LOG")} > 0)

Moral of the story

Don't believe the line number the error message says.

Upvotes: 0

Views: 161

Answers (0)

Related Questions