To store date consistently in one format in VARCHAR column

255 views Asked by At

I am working with an OAF extension in Oracle EBS. We have attribute columns (varchar datatype) provided by Oracle where we can store additional data. We need to store two date fields which are entered by the user.

In the OAF Java page, when user selects the date from the calendar pick and hit save it stores in the format - YYYY-MM-DD in the DB table. eg 2022-05-22

But while being retrieved I need to show that as MM/DD/YYYY to show the dates in alignment in OAF page. The problem here is that next time (2nd time onwards) when we try to save (not by selecting the calendar again as dates are already populated in the view) it's saved in the format MM/DD/YYYY. And there onwards the below view query fails.

select TO_CHAR(TO_DATE(2022-05-22, 'YYYY/MM/DD'),'MM/DD/YYYY') from dual;

Is there a way I can always enforce to store the value as MM/DD/YYYY either in the JAVA code or the PL/SQL Package that's being called. I am basically retrieving the field value in JAVA and invoking the PL/SQL procedure to update it in the table.

DBUtil.setString((OraclePreparedStatement)oracleCallableStatement, b1++, busClassVORowImpl.getAttribute1()) DBUtil.setString((OraclePreparedStatement)oracleCallableStatement, b1++, busClassVORowImpl.getAttribute2())

0

There are 0 answers