6-5. Converting Strings to Timestamps

Problem

You are working with a series of strings. You want to convert them into timestamps.

Solution

Use the TO_TIMESTAMP function to convert the strings into timestamps. In this example, a trigger is created that will log an INSERT into the JOBS table. The logging table consists of two columns. The first column is used to store the date of the transaction, and it is of type TIMESTAMP WITH LOCAL TIME ZONE. The second column is used to contain a DESCRIPTION of type VARCHAR2. The trigger that performs the logging needs to combine a sysdate and a time zone value into a string prior to converting it into a TIMESTAMP.

First, let's create the table that will be used to log the changes on the JOBS table:

CREATE ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.