Wednesday, May 11, 2016

ORA-01861: literal does not match format string (SOA Date time formatting error)

Error:
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ReadQuotesFromStagingDbSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [ReadQuotesFromStagingDbSelect], Descriptor name: [ReadQuotesFromStagingDb.XxlscQuoteIntHeaderTbl]. Caused by java.sql.SQLDataException: ORA-01861: literal does not match format string . See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. To classify it as retriable instead add property nonRetriableErrorCodes with value "-1861" to your deployment descriptor (i.e. weblogic-ra.xml). To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff. All properties are integers. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.

Use Case:
If we want to get the latest records that are updated recently, we use the condition that the LASTUPDATED_DATE greater than or equal to the input date time parameter say afterDate.

Now the afterDate field is added as the input parameter to the DB adapter call, and the afterDate is always a String.  

If we are not passing the input date time in the default format (say DD-MON-YYYY), then we get the above mentioned biding error of ORA-01861: literal does not match format string

Solution:  The solution is to send the input dateTime in a proper format and then use the same format in the DB Adapter Query.  Means converting string to oracle date format.

1. Take a  dateTime type field as input parameter in the BPEL process.

2. Use the format  "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]"  in the XSLT  and convert to a      formatted string.    
Ex:     

3. User the TO_DATE function in the query that is called from the DBAdapter and user the format  string as   'YYYY-MM-DD"T"HH24:MI:SS'

                                Ex:   TO_DATE('2011-07-28T23:54:14', 'YYYY-MM-DD"T"HH24:MI:SS')


No comments: