Skip to content
Advertisement

How to convert varchar2 input parameter to timestamp in stored procedure

We are using a proprietary product to develop our application. This product is capable of connecting to Oracle DB and executes SQL queries and stored procedures. However, today we found a weird issue that this product is not able to execute a stored procedure if there is a timestamp input parameter in stored procedure.

We are now trying to change ‘p_timestamp’ input parameter from timestamp to varchar2. So, application will send timestamp value as a string and then before/while executing insert statement inside stored procedure we want to convert this varchar2 value into timestamp. Also, this timestamp should be stored in UTC time zone.

How to convert the ‘p_timestamp’ varchar2 input parameter into timestamp?

Table:

Stored procedure:

Advertisement

Answer

Assuming that your input is in ISO8601 format with fractional seconds and a time zone then:

If it is in a different format then change the format model to suit your data.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement